Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cake-bot
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Oleksandr Barabash
cake-bot
Commits
a4ef0c6a
Commit
a4ef0c6a
authored
Oct 20, 2022
by
Oleksandr Barabash
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
teams app generator fixes
parent
0b32b099
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
4 deletions
+28
-4
color.png
assets/teams_app_items/color.png
+0
-0
outline.png
assets/teams_app_items/outline.png
+0
-0
config.py
config.py
+1
-0
teams_app_generator.py
utils/teams_app_generator.py
+27
-4
No files found.
assets/teams_app_items/color
_192x192
.png
→
assets/teams_app_items/color.png
View file @
a4ef0c6a
File moved
assets/teams_app_items/outline
_32x32
.png
→
assets/teams_app_items/outline.png
View file @
a4ef0c6a
File moved
config.py
View file @
a4ef0c6a
...
...
@@ -30,6 +30,7 @@ class TaskModuleConfig:
"https://fake.s1z.info/show-channel.html"
)
WIDTH
=
"large"
HEIGHT
=
"large"
VALID_DOMAINS
=
os
.
environ
.
get
(
"VALID_DOMAINS"
,
'[{"validDomain": ""}]'
)
class
AppConfig
:
...
...
utils/teams_app_generator.py
View file @
a4ef0c6a
...
...
@@ -2,9 +2,11 @@
import
asyncio
import
json
import
os
from
urllib.parse
import
urlparse
from
zipfile
import
ZipFile
,
ZIP_DEFLATED
from
config
import
AppConfig
,
TeamsAppConfig
from
config
import
AppConfig
,
TeamsAppConfig
,
TaskModuleConfig
from
utils.json_func
import
json_loads
manifest
=
{
"$schema"
:
"https://developer.microsoft.com/en-us/json-schemas/teams/v1.14/MicrosoftTeams.schema.json"
,
...
...
@@ -27,8 +29,8 @@ manifest = {
"short"
:
"Cakebot-3"
,
"full"
:
"Cakebot-3 Bot"
},
"icons"
:
{
"outline"
:
"outline
_32x32
.png"
,
"color"
:
"color
_192x192
.png"
"outline"
:
"outline.png"
,
"color"
:
"color.png"
},
"accentColor"
:
"#ffffff"
,
"staticTabs"
:
[
...
...
@@ -56,6 +58,24 @@ class TeamsAppGenerator:
""" Teams App Generator implementation """
@staticmethod
def
get_valid_domains
():
""" get valid domains """
valid_domains
=
[]
domain_items
=
json_loads
(
TaskModuleConfig
.
VALID_DOMAINS
,
[])
for
domain_item
in
domain_items
:
valid_domain
=
domain_item
.
get
(
"validDomain"
,
""
)
if
valid_domain
.
find
(
"://"
)
<
0
:
valid_domain
=
"{}{}"
.
format
(
"https://"
,
valid_domain
)
valid_domain
=
urlparse
(
valid_domain
)
.
hostname
if
valid_domain
:
valid_domains
.
append
(
valid_domain
)
default_domain
=
urlparse
(
TaskModuleConfig
.
URL
)
.
hostname
if
default_domain
and
default_domain
not
in
valid_domains
:
valid_domains
.
append
(
default_domain
)
return
valid_domains
@staticmethod
def
gen_manifest
():
""" Generate manifest """
# ID
...
...
@@ -81,7 +101,10 @@ class TeamsAppGenerator:
# WebAppInfo
web_app_info
=
dict
(
id
=
AppConfig
.
APP_ID
,
resource
=
""
)
manifest
.
update
(
dict
(
webApplicationInfo
=
web_app_info
))
#
# Valid domains
valid_domains
=
TeamsAppGenerator
.
get_valid_domains
()
manifest
.
update
(
dict
(
validDomains
=
valid_domains
))
with
open
(
TeamsAppConfig
.
manifest
,
"w"
)
as
f
:
f
.
write
(
json
.
dumps
(
manifest
))
f
.
flush
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment