Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mattermost-matchmaker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
JetBrains YouTrack
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KSZK
Open Source
mattermost-matchmaker
Commits
1c92a99a
Commit
1c92a99a
authored
Feb 28, 2021
by
Tamas Kiss
Browse files
Options
Downloads
Patches
Plain Diff
Add single run option
parent
58c6cdb0
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
coffee_bot/run.py
+72
-0
72 additions, 0 deletions
coffee_bot/run.py
with
72 additions
and
0 deletions
coffee_bot/run.py
0 → 100755
+
72
−
0
View file @
1c92a99a
#!/usr/bin/env python3
import
argparse
import
mattermost
from
coffee_bot.match_making
import
matching_in_channel
if
__name__
==
"
__main__
"
:
parser
=
argparse
.
ArgumentParser
(
description
=
"
Make matches between channel members
"
)
parser
.
add_argument
(
"
--channel-id
"
,
required
=
True
)
parser
.
add_argument
(
"
--minimum-members
"
,
type
=
int
,
default
=
4
,
required
=
False
,
help
=
(
"
Don
'
t start the matchmaking process if there is less than this many members of the channel.
"
"
Default value is 4.
"
))
parser
.
add_argument
(
"
--group-size
"
,
type
=
int
,
default
=
2
,
required
=
False
,
help
=
(
"
Size of the created groups. It can happen that there is a leftover group with less than
"
"
this many members, but there will be no group created with less than 2 members.
"
"
GROUP_SIZE has to be at least 2! Default value is 2
"
))
parser
.
add_argument
(
"
--too-few-message
"
,
type
=
str
,
default
=
None
,
required
=
False
,
help
=
(
"
Message sent to the channel specified by CHANNEL_ID in case there is less than
"
"
MINIMUM_MEMBERS available members for matchmaking.
"
))
parser
.
add_argument
(
"
--group-hail-message
"
,
type
=
str
,
default
=
None
,
required
=
False
,
help
=
(
"
Message sent to the group after making a match
"
))
parser
.
add_argument
(
"
--left-out-message
"
,
type
=
str
,
default
=
None
,
required
=
False
,
help
=
(
"
Message sent for the channel specified by CHANNEL_ID in case someone had to be left out.
"
"
It can be a python format string, the left out user
'
s data is available in the variable user.
"
))
parser
.
add_argument
(
"
--mattermost-url
"
,
type
=
str
,
default
=
None
,
required
=
False
,
help
=
(
"
the URL for the mattermost API (including /api). Defaults to environment variable
"
"
MATTERMOST_URL
"
))
parser
.
add_argument
(
"
--mattermost-token
"
,
type
=
str
,
default
=
None
,
required
=
False
,
help
=
(
"
the access token for the bot user. Defaults to environment variable MATTERMOST_TOKEN
"
))
args
=
parser
.
parse_args
()
if
args
.
group_size
<
2
:
parser
.
error
(
"
GROUP_SIZE has to be at least 2
"
)
if
args
.
mattermost_url
is
None
:
from
.config
import
MATTERMOST_URL
args
.
mattermost_url
=
MATTERMOST_URL
if
args
.
mattermost_token
is
None
:
from
.config
import
MATTERMOST_TOKEN
args
.
mattermost_token
=
MATTERMOST_TOKEN
run
(
**
args
)
#pylint: disable=too-many-arguments
def
run
(
mattermost_url
,
mattermost_token
,
channel_id
,
minimum_members
,
group_size
,
too_few_message
,
group_hail_message
,
left_out_message
):
client
=
mattermost
.
MMApi
(
mattermost_url
)
client
.
login
(
bearer
=
mattermost_token
)
matching_in_channel
(
client
=
client
,
channel_id
=
channel_id
,
group_size
=
group_size
,
group_hail
=
group_hail_message
,
left_out_message
=
left_out_message
,
too_few_message
=
too_few_message
,
minimum_members
=
minimum_members
,
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment