Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
flynn
tractor
Commits
3211407d
Commit
3211407d
authored
Nov 15, 2020
by
flynn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mooooore
parent
9b3a842f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
16 deletions
+35
-16
app.py
app.py
+34
-15
config.py
config.py
+1
-1
No files found.
app.py
View file @
3211407d
...
...
@@ -22,29 +22,48 @@ def requires_token(token_name):
return
decorator
"""
app_1 | {'channel_id': '8dgd5uzuq7gbbff6qy6t631qzw',
app_1 | 'channel_name': '357qk94hgtgxjd6a7fty8n3jha__bjsx9gnigf8e3mpuehgt8pkamo',
app_1 | 'command': '/troll_add_point',
app_1 | 'response_url': 'https://mattermost.zeus.gent/hooks/commands/z63r59zkrpyidqpcweh8kfc17r',
app_1 | 'team_domain': 'zeus',
app_1 | 'team_id': 'pbix1kziz7be3ntjoguf9c3cay',
app_1 | 'text': '@flynn',
app_1 | 'trigger_id': 'NXU5OHNkbmdldG5kOWZlbWZlcmd6OXFrNXk6MzU3cWs5NGhndGd4amQ2YTdmdHk4bjNqaGE6MTYwNTQwMzYwMTEyMTpNRVFDSUNwdFZYbk9ta2hORFhEdmFVRExIUnFRYVUvK3ZFTGZtN25IeUNIVG40R0hBaUIvcUZldytSVC9BSUs2Ukw5SU5BVlVuOC9zS3JUN0dlMnh5bFBadU8vc3FRPT0=',
app_1 | 'user_id': '357qk94hgtgxjd6a7fty8n3jha',
app_1 | 'user_mentions': 'flynn',
app_1 | 'user_mentions_ids': 'bjsx9gnigf8e3mpuehgt8pkamo',
app_1 | 'user_name': 'hannes'}
"""
@
app
.
route
(
"/troll_add_point"
,
methods
=
[
"POST"
])
@
requires_token
(
'troll_add_point'
)
def
change
():
# Get the channel, the user and the victim
channel
=
request
.
form
[
'channel_id'
]
channel_name
=
request
.
form
[
"channel_name"
]
caller
=
request
.
form
[
'user_id'
]
caller_name
=
request
.
form
[
'user_name'
]
def
handle_change
(
amount
:
int
):
caller
=
request
.
form
[
'user_name'
]
# victim_name = request.form['user'].strip()
if
caller
==
"flynn"
or
caller
==
"hannes"
:
pprint
(
request
.
form
)
print
(
"test"
)
users
=
request
.
form
[
'user_mentions'
]
print
(
users
)
print
(
"Change score for ^ with "
)
print
(
amount
)
if
caller
==
"flynn"
or
caller
==
"hannes"
:
print
(
"Received data"
)
return
""
,
200
return
""
else
:
return
"NO"
,
403
return
"NO >:("
@
app
.
route
(
"/troll_add_point"
,
methods
=
[
"POST"
])
@
requires_token
(
'troll_add_point'
)
def
add
():
handle_change
(
1
)
@
requires_token
(
'troll_remove_point'
)
@
app
.
route
(
"/troll_remove_point"
,
methods
=
[
"POST"
])
def
remove
():
handle_change
(
-
1
)
@
app
.
route
(
'/troll_list_points'
,
methods
=
[
"GET"
])
@
requires_token
(
'troll_list_points'
)
def
list_points
():
return
""
,
204
return
""
config.py
View file @
3211407d
...
...
@@ -2,6 +2,6 @@
tokens
=
{
'troll_add_point'
:
'abc'
,
'trol_remove_point'
:
'def'
,
'trol
l
_remove_point'
:
'def'
,
'troll_list_points'
:
'ghi'
}
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