Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
P
projet i2
Project
Project
Details
Activity
Releases
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
Samy Haffoudhi
projet i2
Commits
f092fd98
Commit
f092fd98
authored
Dec 20, 2021
by
Tanguy
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of git.centralenantesetudes.fr:shaffoudhi/projet-i2
parents
ea5bb7ba
2b5bda16
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
51 deletions
+22
-51
app.py
bot/app.py
+6
-51
message_auto.py
bot/message_auto.py
+16
-0
No files found.
bot/app.py
View file @
f092fd98
import
os
from
slack_bolt
import
App
app
=
App
(
...
...
@@ -7,56 +6,12 @@ app = App(
signing_secret
=
os
.
environ
.
get
(
"SLACK_SIGNING_SECRET"
)
)
@
app
.
event
(
"app_home_opened"
)
def
update_home_tab
(
client
,
event
,
logger
):
try
:
# views.publish is the method that your app uses to push a view to the Home tab
client
.
views_publish
(
# the user that opened your app's app home
user_id
=
event
[
"user"
],
# the view object that appears in the app home
view
=
{
"type"
:
"home"
,
"callback_id"
:
"home_view"
,
# body of the view
"blocks"
:
[
{
"type"
:
"section"
,
"text"
:
{
"type"
:
"mrkdwn"
,
"text"
:
"*Bienvenue sur l'app du projet i2* :tada:"
}
},
{
"type"
:
"divider"
},
{
"type"
:
"section"
,
"text"
:
{
"type"
:
"mrkdwn"
,
"text"
:
"Bouton totalement inutile ci-dessous."
}
},
{
"type"
:
"actions"
,
"elements"
:
[
{
"type"
:
"button"
,
"text"
:
{
"type"
:
"plain_text"
,
"text"
:
"Clique quand même !"
}
}
]
}
]
}
)
except
Exception
as
e
:
logger
.
error
(
f
"Error publishing home tab: {e}"
)
@
app
.
event
(
"channel_created"
)
def
join_channel
(
event
,
client
):
channel
=
event
[
'channel'
]
if
channel
[
'name'
][
0
]
==
'2'
:
client
.
conversations_join
(
channel
=
channel
[
'id'
])
client
.
chat_postMessage
(
channel
=
channel
[
'id'
],
text
=
"Salut !"
)
if
__name__
==
"__main__"
:
app
.
start
(
port
=
int
(
os
.
environ
.
get
(
"PORT"
,
3000
)))
bot/message_auto.py
0 → 100644
View file @
f092fd98
import
os
from
slack_sdk
import
WebClient
from
slack_sdk.errors
import
SlackApiError
client
=
WebClient
(
token
=
os
.
environ
.
get
(
"SLACK_BOT_TOKEN"
))
try
:
result
=
client
.
conversations_list
(
types
=
"public_channel, private_channel"
)
for
response
in
result
:
for
channel
in
result
[
"channels"
]:
if
(
channel
[
"name"
][
0
]
==
'2'
)
and
(
not
channel
[
"is_archived"
]):
client
.
chat_postMessage
(
channel
=
channel
[
"id"
],
text
=
"Salut ! Ceci est un test :grin:"
)
except
SlackApiError
as
e
:
print
(
f
"Error: {e}"
)
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