fixing more telegram bugs
This commit is contained in:
parent
a0bd5e69e1
commit
6cac81e444
|
@ -11,7 +11,10 @@ class TelegramBot(Bot):
|
||||||
def crawl(self, user):
|
def crawl(self, user):
|
||||||
tb = Telegram(user.get_telegram_credentials())
|
tb = Telegram(user.get_telegram_credentials())
|
||||||
seen_tg = user.get_seen_tg()
|
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 = []
|
reports = []
|
||||||
for update in updates:
|
for update in updates:
|
||||||
try:
|
try:
|
||||||
|
@ -45,4 +48,4 @@ class TelegramBot(Bot):
|
||||||
tb.send_message(subscriber_id, text).wait()
|
tb.send_message(subscriber_id, text).wait()
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.error('Error telegramming: ' + user.get_city() + ': '
|
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,
|
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
|
||||||
user_id INTEGER,
|
user_id INTEGER,
|
||||||
tg_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 (
|
CREATE TABLE IF NOT EXISTS twitter_request_tokens (
|
||||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
|
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
|
||||||
|
@ -264,6 +264,8 @@ u\d\d?
|
||||||
(uid, json['email']))
|
(uid, json['email']))
|
||||||
self.execute("""INSERT INTO telegram_accounts (user_id, apikey,
|
self.execute("""INSERT INTO telegram_accounts (user_id, apikey,
|
||||||
active) VALUES(?, ?, ?);""", (uid, "", 1))
|
active) VALUES(?, ?, ?);""", (uid, "", 1))
|
||||||
|
self.execute("INSERT INTO seen_telegrams (user_id, tg_id) VALUES (?,?);",
|
||||||
|
(uid, 0))
|
||||||
self.commit()
|
self.commit()
|
||||||
user = User(uid)
|
user = User(uid)
|
||||||
self.execute("INSERT INTO seen_mail (user_id, mail_date) VALUES (?,?)",
|
self.execute("INSERT INTO seen_mail (user_id, mail_date) VALUES (?,?)",
|
||||||
|
|
2
user.py
2
user.py
|
@ -104,7 +104,7 @@ schlitz
|
||||||
def get_telegram_subscribers(self):
|
def get_telegram_subscribers(self):
|
||||||
db.execute("""SELECT subscriber_id
|
db.execute("""SELECT subscriber_id
|
||||||
FROM telegram_subscribers
|
FROM telegram_subscribers
|
||||||
WHERE user_id = ? AND active = 1;""",
|
WHERE user_id = ?;""",
|
||||||
(self.uid,))
|
(self.uid,))
|
||||||
rows = db.cur.fetchall()
|
rows = db.cur.fetchall()
|
||||||
return rows
|
return rows
|
||||||
|
|
Loading…
Reference in a new issue