Compare commits

...

8 commits

Author SHA1 Message Date
b3yond 8c778927ee fixing import error 2019-05-17 20:42:13 +02:00
b3yond 079166e74c
Merge pull request #86 from ticketfrei/masto502
don't log Mastodon 502 errors.
2019-05-04 12:04:51 +02:00
b3yond fb15771cf2
Merge pull request #93 from ticketfrei/images
Notify that telegram image reports are not supported. #90
2019-05-04 10:23:34 +02:00
sid d1b11fe932
Update active_bots/telegrambot.py
Co-Authored-By: b3yond <b3yond@riseup.net>
2019-05-04 10:22:03 +02:00
b3yond c30f9d8eaa
Merge pull request #87 from ticketfrei/fix-none-error
fixed wrong exception
2019-05-03 17:11:25 +02:00
b3yond 7a7e8f0a30 Notify that telegram image reports are not supported. #90 2019-05-03 14:35:06 +02:00
b3yond e18244e149 don't log Mastodon 502 errors. 2019-05-03 10:07:16 +02:00
b3yond cd3c8be2dc fixed wrong exception 2019-02-19 16:16:21 +01:00
3 changed files with 12 additions and 6 deletions

View file

@ -2,7 +2,7 @@
from bot import Bot from bot import Bot
import logging import logging
from mastodon import Mastodon import mastodon
import re import re
from report import Report from report import Report
@ -19,14 +19,14 @@ class MastodonBot(Bot):
""" """
mentions = [] mentions = []
try: try:
m = Mastodon(*user.get_masto_credentials()) m = mastodon.Mastodon(*user.get_masto_credentials())
except TypeError: except TypeError:
# logger.error("No Mastodon Credentials in database.", exc_info=True) # logger.error("No Mastodon Credentials in database.", exc_info=True)
return mentions return mentions
try: try:
notifications = m.notifications() notifications = m.notifications()
except Exception: except mastodon.MastodonServerError:
logger.error("Unknown Mastodon API Error.", exc_info=True) logger.error("Unknown Mastodon API Error: 502")
return mentions return mentions
for status in notifications: for status in notifications:
if (status['type'] == 'mention' and if (status['type'] == 'mention' and
@ -54,7 +54,7 @@ class MastodonBot(Bot):
def post(self, user, report): def post(self, user, report):
try: try:
m = Mastodon(*user.get_masto_credentials()) m = mastodon.Mastodon(*user.get_masto_credentials())
except TypeError: except TypeError:
return # no mastodon account for this user. return # no mastodon account for this user.
if report.source == self: if report.source == self:

View file

@ -32,6 +32,12 @@ class TelegramBot(Bot):
logger.error("Unknown Telegram error code: " + str(update)) logger.error("Unknown Telegram error code: " + str(update))
return reports return reports
user.save_seen_tg(update.update_id) user.save_seen_tg(update.update_id)
if update.message.photo:
tb.send_message(
update.message.sender.id,
"Sending Photos is not supported for privacy reasons. Can "
"you describe it as text instead?")
continue
if update.message.text.lower() == "/start": if update.message.text.lower() == "/start":
user.add_telegram_subscribers(update.message.sender.id) user.add_telegram_subscribers(update.message.sender.id)
tb.send_message( tb.send_message(

View file

@ -73,7 +73,7 @@ class TwitterBot(Bot):
def post(self, user, report): def post(self, user, report):
try: try:
api = self.get_api(user) api = self.get_api(user)
except IndexError: except TypeError:
return # no twitter account for this user. return # no twitter account for this user.
try: try:
if report.source == self: if report.source == self: