ig: survive exceptions by ig library - fixes #10. loc: allow multi-word search strings
This commit is contained in:
parent
325e1e623c
commit
d8d38415d1
|
@ -1,3 +1,5 @@
|
||||||
|
import traceback
|
||||||
|
import sys
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from random import randrange
|
from random import randrange
|
||||||
|
|
||||||
|
@ -34,11 +36,13 @@ class MatrixModule:
|
||||||
' account that does not exist - deleting from room')
|
' account that does not exist - deleting from room')
|
||||||
self.account_rooms[roomid].remove(account)
|
self.account_rooms[roomid].remove(account)
|
||||||
bot.save_settings()
|
bot.save_settings()
|
||||||
|
except Exception:
|
||||||
|
print('Polling instagram account failed:')
|
||||||
|
traceback.print_exc(file=sys.stderr)
|
||||||
|
|
||||||
self.first_run = False
|
self.first_run = False
|
||||||
|
|
||||||
async def poll_account(self, bot, account, roomid, send_messages):
|
async def poll_account(self, bot, account, roomid, send_messages):
|
||||||
print('polling', account, roomid, send_messages)
|
|
||||||
medias = self.instagram.get_medias(account, 5)
|
medias = self.instagram.get_medias(account, 5)
|
||||||
|
|
||||||
for media in medias:
|
for media in medias:
|
||||||
|
|
|
@ -41,10 +41,12 @@ class MatrixModule:
|
||||||
args.pop(0)
|
args.pop(0)
|
||||||
if len(args) == 0:
|
if len(args) == 0:
|
||||||
await bot.send_text(room, 'Usage: !loc <location name>')
|
await bot.send_text(room, 'Usage: !loc <location name>')
|
||||||
if len(args) == 1:
|
else:
|
||||||
query = event.body[4:]
|
query = event.body[4:]
|
||||||
geolocator = Nominatim(user_agent=bot.appid)
|
geolocator = Nominatim(user_agent=bot.appid)
|
||||||
|
print('loc: looking up', query, '..')
|
||||||
location = geolocator.geocode(query)
|
location = geolocator.geocode(query)
|
||||||
|
print('loc rx', location)
|
||||||
if location:
|
if location:
|
||||||
locationmsg = {
|
locationmsg = {
|
||||||
"body": str(location.address),
|
"body": str(location.address),
|
||||||
|
|
Loading…
Reference in New Issue