Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
maubot-rt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
isgphys
maubot-rt
Commits
60cccccd
Commit
60cccccd
authored
5 years ago
by
Sven Mäder
Browse files
Options
Downloads
Patches
Plain Diff
Not async
parent
189fdb27
Branches
step_test_cto
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
rt.py
+16
-20
16 additions, 20 deletions
rt.py
with
16 additions
and
20 deletions
rt.py
+
16
−
20
View file @
60cccccd
...
...
@@ -47,7 +47,7 @@ class RT(Plugin):
def
get_config_class
(
cls
)
->
Type
[
BaseProxyConfig
]:
return
Config
def
is_
valid_id
(
self
,
id
:
str
)
->
bool
:
def
valid_id
(
self
,
id
:
str
)
->
bool
:
return
True
if
self
.
regex_id
.
match
(
id
)
else
False
def
filter_dict
(
self
,
raw
:
dict
,
keys
:
Set
)
->
dict
:
...
...
@@ -59,14 +59,11 @@ class RT(Plugin):
def
html_link
(
self
,
id
:
str
)
->
str
:
return
f
'
<a href=
"
{
self
.
display
}
?id=
{
id
}
"
>rt#
{
id
}
</a>
'
async
def
can_manage
(
self
,
evt
:
MessageEvent
)
->
bool
:
def
can_manage
(
self
,
evt
:
MessageEvent
)
->
bool
:
if
evt
.
sender
in
self
.
whitelist
:
return
True
return
False
async
def
_username
(
self
,
evt
:
MessageEvent
)
->
str
:
return
evt
.
sender
[
1
:].
split
(
'
:
'
)[
0
]
async
def
_member_mxids
(
self
,
room_id
:
RoomID
)
->
Dict
[
UserID
,
str
]:
room_members
=
await
self
.
client
.
get_joined_members
(
room_id
)
member_mxids
=
{}
...
...
@@ -149,7 +146,7 @@ class RT(Plugin):
@rt.subcommand
(
'
properties
'
,
aliases
=
(
'
p
'
,
'
prop
'
),
help
=
'
Show all ticket properties.
'
)
@command.argument
(
'
id
'
,
'
ticket id
'
,
parser
=
str
)
async
def
properties
(
self
,
evt
:
MessageEvent
,
id
:
str
)
->
None
:
if
not
await
self
.
can_manage
(
evt
)
or
not
self
.
is_
valid_id
(
id
):
if
not
self
.
can_manage
(
evt
)
or
not
self
.
valid_id
(
id
):
return
await
evt
.
mark_read
()
properties_dict
=
await
self
.
_properties
(
id
)
...
...
@@ -159,7 +156,7 @@ class RT(Plugin):
@rt.subcommand
(
'
resolve
'
,
aliases
=
(
'
r
'
,
'
res
'
),
help
=
'
Mark the ticket as resolved.
'
)
@command.argument
(
'
id
'
,
'
ticket id
'
,
parser
=
str
)
async
def
resolve
(
self
,
evt
:
MessageEvent
,
id
:
str
)
->
None
:
if
not
await
self
.
can_manage
(
evt
)
or
not
self
.
is_
valid_id
(
id
):
if
not
self
.
can_manage
(
evt
)
or
not
self
.
valid_id
(
id
):
return
await
evt
.
mark_read
()
await
self
.
_edit
(
id
,
{
'
Status
'
:
'
resolved
'
})
...
...
@@ -168,7 +165,7 @@ class RT(Plugin):
@rt.subcommand
(
'
open
'
,
aliases
=
(
'
o
'
,
'
op
'
),
help
=
'
Mark the ticket as open.
'
)
@command.argument
(
'
id
'
,
'
ticket id
'
,
parser
=
str
)
async
def
open
(
self
,
evt
:
MessageEvent
,
id
:
str
)
->
None
:
if
not
await
self
.
can_manage
(
evt
)
or
not
self
.
is_
valid_id
(
id
):
if
not
self
.
can_manage
(
evt
)
or
not
self
.
valid_id
(
id
):
return
await
evt
.
mark_read
()
await
self
.
_edit
(
id
,
{
'
Status
'
:
'
open
'
})
...
...
@@ -177,7 +174,7 @@ class RT(Plugin):
@rt.subcommand
(
'
stall
'
,
aliases
=
(
'
st
'
,
'
sta
'
),
help
=
'
Mark the ticket as stalled.
'
)
@command.argument
(
'
id
'
,
'
ticket id
'
,
parser
=
str
)
async
def
stall
(
self
,
evt
:
MessageEvent
,
id
:
str
)
->
None
:
if
not
await
self
.
can_manage
(
evt
)
or
not
self
.
is_
valid_id
(
id
):
if
not
self
.
can_manage
(
evt
)
or
not
self
.
valid_id
(
id
):
return
await
evt
.
mark_read
()
await
self
.
_edit
(
id
,
{
'
Status
'
:
'
stalled
'
})
...
...
@@ -186,7 +183,7 @@ class RT(Plugin):
@rt.subcommand
(
'
delete
'
,
aliases
=
(
'
d
'
,
'
del
'
),
help
=
'
Mark the ticket as deleted.
'
)
@command.argument
(
'
id
'
,
'
ticket id
'
,
parser
=
str
)
async
def
delete
(
self
,
evt
:
MessageEvent
,
id
:
str
)
->
None
:
if
not
await
self
.
can_manage
(
evt
)
or
not
self
.
is_
valid_id
(
id
):
if
not
self
.
can_manage
(
evt
)
or
not
self
.
valid_id
(
id
):
return
await
evt
.
mark_read
()
await
self
.
_edit
(
id
,
{
'
Status
'
:
'
deleted
'
})
...
...
@@ -194,7 +191,7 @@ class RT(Plugin):
@rt.subcommand
(
'
autoresolve
'
,
help
=
'
Ask the bot to automatically answer and resolve tickets.
'
)
async
def
autoresolve
(
self
,
evt
:
MessageEvent
)
->
None
:
if
not
await
self
.
can_manage
(
evt
):
if
not
self
.
can_manage
(
evt
):
return
await
evt
.
mark_read
()
await
evt
.
react
(
'
😂🤣🦄🌈
'
)
...
...
@@ -203,7 +200,7 @@ class RT(Plugin):
@command.argument
(
'
id
'
,
'
ticket id
'
,
parser
=
str
)
@command.argument
(
'
comment
'
,
'
comment text
'
,
pass_raw
=
True
)
async
def
comment
(
self
,
evt
:
MessageEvent
,
id
:
str
,
comment
:
str
)
->
None
:
if
not
await
self
.
can_manage
(
evt
)
or
not
self
.
is_
valid_id
(
id
):
if
not
self
.
can_manage
(
evt
)
or
not
self
.
valid_id
(
id
):
return
await
evt
.
mark_read
()
await
self
.
_comment
(
id
,
comment
)
...
...
@@ -212,7 +209,7 @@ class RT(Plugin):
@rt.subcommand
(
'
history
'
,
aliases
=
(
'
h
'
,
'
hist
'
),
help
=
'
Get a list of all history entries.
'
)
@command.argument
(
'
id
'
,
'
ticket id
'
,
parser
=
str
)
async
def
history
(
self
,
evt
:
MessageEvent
,
id
:
str
)
->
None
:
if
not
await
self
.
can_manage
(
evt
)
or
not
self
.
is_
valid_id
(
id
):
if
not
self
.
can_manage
(
evt
)
or
not
self
.
valid_id
(
id
):
return
await
evt
.
mark_read
()
history_dict
=
await
self
.
_history
(
id
)
...
...
@@ -223,7 +220,7 @@ class RT(Plugin):
@command.argument
(
'
id
'
,
'
ticket id
'
,
parser
=
str
)
@command.argument
(
'
entryid
'
,
'
history entry id
'
,
parser
=
str
)
async
def
entry
(
self
,
evt
:
MessageEvent
,
id
:
str
,
entryid
:
str
)
->
None
:
if
not
await
self
.
can_manage
(
evt
)
or
not
self
.
is_
valid_id
(
id
):
if
not
self
.
can_manage
(
evt
)
or
not
self
.
valid_id
(
id
):
return
await
evt
.
mark_read
()
entry_dict
=
await
self
.
_entry
(
id
,
entryid
)
...
...
@@ -233,7 +230,7 @@ class RT(Plugin):
@rt.subcommand
(
'
last
'
,
aliases
=
(
'
l
'
,
'
la
'
),
help
=
'
Gets the last entry.
'
)
@command.argument
(
'
id
'
,
'
ticket id
'
,
parser
=
str
)
async
def
last
(
self
,
evt
:
MessageEvent
,
id
:
str
)
->
None
:
if
not
await
self
.
can_manage
(
evt
)
or
not
self
.
is_
valid_id
(
id
):
if
not
self
.
can_manage
(
evt
)
or
not
self
.
valid_id
(
id
):
return
await
evt
.
mark_read
()
history
=
await
self
.
_history
(
id
)
...
...
@@ -246,7 +243,7 @@ class RT(Plugin):
@rt.subcommand
(
'
show
'
,
aliases
=
(
'
s
'
,
'
sh
'
),
help
=
'
Show all information about the ticket.
'
)
@command.argument
(
'
id
'
,
'
ticket id
'
,
parser
=
str
)
async
def
show
(
self
,
evt
:
MessageEvent
,
id
:
str
)
->
None
:
if
not
await
self
.
can_manage
(
evt
)
or
not
self
.
is_
valid_id
(
id
):
if
not
self
.
can_manage
(
evt
)
or
not
self
.
valid_id
(
id
):
return
await
evt
.
mark_read
()
prop_dict
=
await
self
.
_properties
(
id
)
...
...
@@ -265,12 +262,11 @@ class RT(Plugin):
@rt.subcommand
(
'
take
'
,
aliases
=
(
'
t
'
,
'
ta
'
,
'
steal
'
),
help
=
'
Take or steal the ticket.
'
)
@command.argument
(
'
id
'
,
'
ticket id
'
,
parser
=
str
)
async
def
take
(
self
,
evt
:
MessageEvent
,
id
:
str
)
->
None
:
if
not
await
self
.
can_manage
(
evt
)
or
not
self
.
is_
valid_id
(
id
):
if
not
self
.
can_manage
(
evt
)
or
not
self
.
valid_id
(
id
):
return
await
evt
.
mark_read
()
username
=
await
self
.
_username
(
evt
)
displayname
=
await
self
.
_displayname
(
evt
.
room_id
,
evt
.
sender
)
await
self
.
_edit
(
id
,
{
'
Owner
'
:
username
})
await
self
.
_edit
(
id
,
{
'
Owner
'
:
evt
.
sender
[
1
:].
split
(
'
:
'
)[
0
]
})
content
=
TextMessageEventContent
(
msgtype
=
MessageType
.
NOTICE
,
format
=
Format
.
HTML
,
body
=
f
'
{
displayname
}
took rt#
{
id
}
👍️
'
,
...
...
@@ -282,7 +278,7 @@ class RT(Plugin):
@command.argument
(
'
id
'
,
'
ticket id
'
,
parser
=
str
)
@command.argument
(
'
user
'
,
'
matrix user
'
,
parser
=
str
)
async
def
give
(
self
,
evt
:
MessageEvent
,
id
:
str
,
user
:
str
)
->
None
:
if
not
await
self
.
can_manage
(
evt
)
or
not
self
.
is_
valid_id
(
id
):
if
not
self
.
can_manage
(
evt
)
or
not
self
.
valid_id
(
id
):
return
await
evt
.
mark_read
()
member_mxids
=
await
self
.
_member_mxids
(
evt
.
room_id
)
...
...
This diff is collapsed.
Click to expand it.
Sven Mäder
@maedersv
mentioned in commit
68941a11
By maedersv on 2020-04-24T11:45:46
·
4 years ago
Imported
mentioned in commit
68941a11
By maedersv on 2020-04-24T11:45:46
Edited
4 years ago
by
Ghost User
mentioned in commit 68941a11edd2b081015aa7b41a1c68a54d10e2b2 *By maedersv on 2020-04-24T11:45:46*
Toggle commit list
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