Browse Source

try to correct stream bug

v1.2
Dryusdan 2 years ago
parent
commit
02b34b8012
1 changed files with 12 additions and 6 deletions
  1. +12
    -6
      bot.py

+ 12
- 6
bot.py View File

@ -31,12 +31,20 @@ def post_img(mastodon, text, visibility, log, config):
mastodon.status_post("", None, media_ids=[media_dict], sensitive=True, visibility='public', spoiler_text="#NSFW")
class BotListener(StreamListener):
def __init__(self, mastodon, log):
self.mastodon = mastodon;
self.log = log;
self.log.debug("init success")
def on_notification(self, notification):
print("notif")
self.log.debug("notif")
def on_update(self, status):
print("update");
self.log.debug("update");
#def handle_heartbeat():
# self.log.debug("heartbeat")
def main():
@ -53,14 +61,12 @@ def main():
if args.img:
post_img(mastodon, "NSFW", 1, log, config_file)
elif args.stream:
print("streaming")
stream = BotListener();
stream = BotListener(mastodon, log);
while True:
try:
print("listening")
log.info("Start listening...")
mastodon.stream_user(stream, async=False)
except Exception as error:
pprint(error);
log.warning('General exception caught: ' + str(error))
time.sleep(0.5)


Loading…
Cancel
Save