fixing more telegram bugs
This commit is contained in:
parent
a0bd5e69e1
commit
6cac81e444
|
@ -11,7 +11,10 @@ class TelegramBot(Bot):
|
|||
def crawl(self, user):
|
||||
tb = Telegram(user.get_telegram_credentials())
|
||||
seen_tg = user.get_seen_tg()
|
||||
updates = tb.get_updates(offset=seen_tg+1).wait()
|
||||
try:
|
||||
updates = tb.get_updates(offset=seen_tg+1).wait()
|
||||
except TypeError:
|
||||
updates = tb.get_updates().wait()
|
||||
reports = []
|
||||
for update in updates:
|
||||
try:
|
||||
|
@ -45,4 +48,4 @@ class TelegramBot(Bot):
|
|||
tb.send_message(subscriber_id, text).wait()
|
||||
except Exception:
|
||||
logger.error('Error telegramming: ' + user.get_city() + ': '
|
||||
+ report.id, exc_info=True)
|
||||
+ str(report.id), exc_info=True)
|
||||
|
|
4
db.py
4
db.py
|
@ -79,7 +79,7 @@ class DB(object):
|
|||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
|
||||
user_id INTEGER,
|
||||
tg_id INTEGER,
|
||||
FOREIGN KEY(user_id) REFERENCES user(id),
|
||||
FOREIGN KEY(user_id) REFERENCES user(id)
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS twitter_request_tokens (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
|
||||
|
@ -264,6 +264,8 @@ u\d\d?
|
|||
(uid, json['email']))
|
||||
self.execute("""INSERT INTO telegram_accounts (user_id, apikey,
|
||||
active) VALUES(?, ?, ?);""", (uid, "", 1))
|
||||
self.execute("INSERT INTO seen_telegrams (user_id, tg_id) VALUES (?,?);",
|
||||
(uid, 0))
|
||||
self.commit()
|
||||
user = User(uid)
|
||||
self.execute("INSERT INTO seen_mail (user_id, mail_date) VALUES (?,?)",
|
||||
|
|
Loading…
Reference in a new issue