Compare commits

...

13 Commits

3 changed files with 34 additions and 3 deletions

View File

@ -152,10 +152,19 @@ echo "Enter your domain name into the following prompt:" && read DOMAIN
# configure nginx
sudo sed -r "s/example.org/$DOMAIN/g" deployment/example.org.conf > /etc/nginx/sites-enabled/$DOMAIN.conf
# create folder for socket & database
# create folder for database
sudo mkdir /var/ticketfrei
sudo chown www-data:www-data -R /var/ticketfrei
# create folder for socket
sudo mkdir /var/run/ticketfrei
sudo chown -R www-data:www-data /var/run/ticketfrei
sudo -s
echo "mkdir /var/run/ticketfrei" >> /etc/rc.local
echo "chown -R www-data:www-data /var/run/ticketfrei" >> /etc/rc.local
echo "service ticketfrei-web restart" >> /etc/rc.local
exit
# change /etc/aliases permissions to be able to receive reports per mail
sudo chown root:www-data /etc/aliases
sudo chmod 664 /etc/aliases

View File

@ -21,12 +21,24 @@ class MastodonBot(Bot):
try:
m = mastodon.Mastodon(*user.get_masto_credentials())
except TypeError:
# logger.error("No Mastodon Credentials in database.", exc_info=True)
# No Mastodon Credentials in database.
return mentions
try:
notifications = m.notifications()
except mastodon.MastodonInternalServerError:
logger.error("Mastodon Error: 500. Server: " + m.instance()['urls']['streaming_api'])
return mentions
except mastodon.MastodonBadGatewayError:
logger.error("Mastodon Error: 502. Server: " + m.instance()['urls']['streaming_api'])
return mentions
except mastodon.MastodonServiceUnavailableError:
logger.error("Mastodon Error: 503. Server: " + m.instance()['urls']['streaming_api'])
return mentions
except mastodon.MastodonGatewayTimeoutError:
logger.error("Mastodon Error: 504. Server: " + m.instance()['urls']['streaming_api'])
return mentions
except mastodon.MastodonServerError:
logger.error("Unknown Mastodon API Error: 502")
logger.error("Unknown Mastodon Server Error. Server: " + m.instance()['urls']['streaming_api'], exc_info=True)
return mentions
for status in notifications:
if (status['type'] == 'mention' and

View File

@ -23,6 +23,7 @@ class TelegramBot(Bot):
# return when telegram returns an error code
if update in [303, 404, 420, 500, 502]:
return reports
# log unusual telegram error messages
if isinstance(update, int):
try:
logger.error("City " + str(user.uid) +
@ -31,13 +32,22 @@ class TelegramBot(Bot):
except TypeError:
logger.error("Unknown Telegram error code: " + str(update))
return reports
# save the last message, so it doesn't get crawled again
user.save_seen_tg(update.update_id)
# complain if message is a photo
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
# complain if message is a media file
if update.message.text is None:
tb.send_message(
update.message.sender.id,
"We only support text reporting for privacy reasons. Can "
"you describe it as text instead?")
continue
if update.message.text.lower() == "/start":
user.add_telegram_subscribers(update.message.sender.id)
tb.send_message(