Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rss
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Falk Rehse
rss
Commits
146174dc
Verified
Commit
146174dc
authored
Jul 30, 2021
by
Timuçin Boldt
Browse files
Options
Downloads
Patches
Plain Diff
continue broadcasting after forbidden send request
parent
a8e714cc
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
rss/bot.py
+8
-5
8 additions, 5 deletions
rss/bot.py
with
8 additions
and
5 deletions
rss/bot.py
+
8
−
5
View file @
146174dc
...
@@ -26,6 +26,7 @@ import feedparser
...
@@ -26,6 +26,7 @@ import feedparser
from
mautrix.util.config
import
BaseProxyConfig
,
ConfigUpdateHelper
from
mautrix.util.config
import
BaseProxyConfig
,
ConfigUpdateHelper
from
mautrix.types
import
(
StateEvent
,
EventType
,
MessageType
,
RoomID
,
EventID
,
from
mautrix.types
import
(
StateEvent
,
EventType
,
MessageType
,
RoomID
,
EventID
,
PowerLevelStateEventContent
)
PowerLevelStateEventContent
)
from
mautrix.errors.request
import
MForbidden
from
maubot
import
Plugin
,
MessageEvent
from
maubot
import
Plugin
,
MessageEvent
from
maubot.handlers
import
command
,
event
from
maubot.handlers
import
command
,
event
...
@@ -118,12 +119,14 @@ class RSSBot(Plugin):
...
@@ -118,12 +119,14 @@ class RSSBot(Plugin):
async
def
_broadcast
(
self
,
feed
:
Feed
,
entry
:
Entry
,
subscriptions
:
List
[
Subscription
])
->
None
:
async
def
_broadcast
(
self
,
feed
:
Feed
,
entry
:
Entry
,
subscriptions
:
List
[
Subscription
])
->
None
:
spam_sleep
=
self
.
config
[
"
spam_sleep
"
]
spam_sleep
=
self
.
config
[
"
spam_sleep
"
]
tasks
=
[
self
.
_send
(
feed
,
entry
,
sub
)
for
sub
in
subscriptions
]
tasks
=
[
self
.
_send
(
feed
,
entry
,
sub
)
for
sub
in
subscriptions
]
if
spam_sleep
>=
0
:
for
task
in
tasks
:
for
task
in
tasks
:
try
:
await
task
await
task
if
spam_sleep
>=
0
:
await
asyncio
.
sleep
(
spam_sleep
,
loop
=
self
.
loop
)
await
asyncio
.
sleep
(
spam_sleep
,
loop
=
self
.
loop
)
else
:
except
MForbidden
as
e
:
await
asyncio
.
gather
(
*
tasks
)
self
.
log
.
warning
(
f
"
Failed to broadcast:
{
e
}
"
)
continue
async
def
_poll_once
(
self
)
->
None
:
async
def
_poll_once
(
self
)
->
None
:
subs
=
self
.
db
.
get_feeds
()
subs
=
self
.
db
.
get_feeds
()
...
...
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