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
faec0688
Commit
faec0688
authored
5 years ago
by
Sven Mäder
Browse files
Options
Downloads
Patches
Plain Diff
Implement reject
parent
b8b4bb68
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
rt.py
+27
-3
27 additions, 3 deletions
rt.py
with
27 additions
and
3 deletions
rt.py
+
27
−
3
View file @
faec0688
...
...
@@ -29,6 +29,7 @@ class RT(Plugin):
regex_properties
=
re
.
compile
(
r
'
([a-zA-z]+): (.+)
'
)
regex_history
=
re
.
compile
(
r
'
([0-9]+): (.+)
'
)
regex_entry
=
re
.
compile
(
r
'
([a-zA-z]+): (.+(?:\n {8}.*)*)
'
,
re
.
MULTILINE
)
regex_assigner
=
re
.
compile
(
r
'
^.*?>(@.+:.+)<.*? assigned
'
)
take_this
=
f
'
(
\U0001F44D
this to take the ticket)
'
interesting
=
[
'
Ticket created
'
,
...
...
@@ -163,7 +164,29 @@ class RT(Plugin):
msgtype
=
MessageType
.
NOTICE
,
format
=
Format
.
HTML
,
body
=
f
'
{
displayname
}
took
{
number
}
'
,
formatted_body
=
f
'
<a href=
"
https://matrix.to/#/
{
evt
.
sender
}
"
>
{
evt
.
sender
}
</a>
'
f
'
took <code>
{
target_ticket
[
0
]
}
</code>
'
)
f
'
took <code>
{
number
}
</code>
'
)
await
self
.
client
.
send_message
(
evt
.
room_id
,
content
)
@command.passive
(
regex
=
r
"
(?:\U0001F595[\U0001F3FB-\U0001F3FF]?)
"
,
field
=
lambda
evt
:
evt
.
content
.
relates_to
.
key
,
event_type
=
EventType
.
REACTION
,
msgtypes
=
None
)
async
def
react_reject
(
self
,
evt
:
ReactionEvent
,
_
:
Tuple
[
str
])
->
None
:
displayname
=
await
self
.
_displayname
(
evt
.
room_id
,
evt
.
sender
)
target_evt
=
await
self
.
client
.
get_event
(
evt
.
room_id
,
evt
.
content
.
relates_to
.
event_id
)
target_ticket
=
self
.
regex_ticket
.
findall
(
target_evt
.
content
.
body
)
target_mxid
=
self
.
regex_assigner
.
findall
(
target_evt
.
content
.
formatted_body
)[
0
]
target_username
=
target_mxid
[
1
:].
split
(
'
:
'
)[
0
]
target_displayname
=
await
self
.
_displayname
(
evt
.
room_id
,
target_mxid
)
if
len
(
target_ticket
)
==
1
:
number
=
target_ticket
[
0
]
await
self
.
_edit
(
number
,
{
'
Owner
'
:
target_username
})
content
=
TextMessageEventContent
(
msgtype
=
MessageType
.
NOTICE
,
format
=
Format
.
HTML
,
body
=
f
'
{
displayname
}
politely rejected
{
number
}
and gave it back to
'
f
'
{
target_displayname
}
'
,
formatted_body
=
f
'
<a href=
"
https://matrix.to/#/
{
evt
.
sender
}
"
>
{
evt
.
sender
}
</a>
'
f
'
politely rejected <code>
{
number
}
</code> and gave it back to
'
f
'
<a href=
"
https://matrix.to/#/
{
target_mxid
}
"
>
{
target_mxid
}
</a>
'
)
await
self
.
client
.
send_message
(
evt
.
room_id
,
content
)
@command.new
(
name
=
lambda
self
:
self
.
prefix
,
...
...
@@ -328,12 +351,13 @@ class RT(Plugin):
target_mxid
=
member_mxids
[
user
]
target_username
=
target_mxid
[
1
:].
split
(
'
:
'
)[
0
]
await
self
.
_edit
(
number
,
{
'
Owner
'
:
target_username
})
react
=
f
'
(
\U0001F44D
to accept,
\U0001F595
to reject)
'
content
=
TextMessageEventContent
(
msgtype
=
MessageType
.
NOTICE
,
format
=
Format
.
HTML
,
body
=
f
'
{
displayname
}
assigned rt#
{
number
}
to
{
user
}
😜
'
,
body
=
f
'
{
displayname
}
assigned rt#
{
number
}
to
{
user
}
😜
{
react
}
'
,
formatted_body
=
f
'
<a href=
"
https://matrix.to/#/
{
evt
.
sender
}
"
>
{
evt
.
sender
}
</a>
'
f
'
assigned
{
self
.
html_link
(
number
)
}
to
'
f
'
<a href=
"
https://matrix.to/#/
{
target_mxid
}
"
>
{
target_mxid
}
</a> 😜
'
)
f
'
<a href=
"
https://matrix.to/#/
{
target_mxid
}
"
>
{
target_mxid
}
</a> 😜
{
react
}
'
)
await
evt
.
respond
(
content
)
@rt.subcommand
(
'
new
'
,
aliases
=
(
'
n
'
,
'
new
'
),
help
=
'
List all unowned new/open tickets.
'
)
...
...
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