Switch stuff and more
This commit is contained in:
parent
0c62833095
commit
70f7dfcc85
|
@ -61,7 +61,6 @@ def mentionHelper(bot, update):
|
||||||
try:
|
try:
|
||||||
feature(bot, update, args[2:])
|
feature(bot, update, args[2:])
|
||||||
except:
|
except:
|
||||||
print(e)
|
|
||||||
feature(bot, update)
|
feature(bot, update)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.exception(e)
|
logging.exception(e)
|
||||||
|
@ -163,6 +162,19 @@ def verify(bot, update, args):
|
||||||
db.deleteToken(update.message.chat_id)
|
db.deleteToken(update.message.chat_id)
|
||||||
update.message.reply_text(bottools.strings.verifyfail)
|
update.message.reply_text(bottools.strings.verifyfail)
|
||||||
|
|
||||||
|
found = None
|
||||||
|
|
||||||
|
for a in dbtools.dbHelper().accounts(cid):
|
||||||
|
try:
|
||||||
|
if twitools.twObject(ato=a[0], ase=a[1]).whoami().strip("@").lower() == args[0].strip("@").lower():
|
||||||
|
found = a
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if found:
|
||||||
|
dbtools.dbHelper().deleteUserByAto(found[0])
|
||||||
|
|
||||||
except:
|
except:
|
||||||
update.message.reply_text(bottools.strings.verifyimp)
|
update.message.reply_text(bottools.strings.verifyimp)
|
||||||
|
|
||||||
|
@ -194,6 +206,11 @@ def switch(bot, update, args):
|
||||||
dbtools.dbHelper().setActive(cid, a[0])
|
dbtools.dbHelper().setActive(cid, a[0])
|
||||||
message.reply_text(bottools.strings.switch % bottools.methods.getTwo(message).whoami().strip("@"))
|
message.reply_text(bottools.strings.switch % bottools.methods.getTwo(message).whoami().strip("@"))
|
||||||
|
|
||||||
|
try:
|
||||||
|
return getTwo(message).getTweet(getTweetID(args[1], cid))
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception(e)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
message.reply_text(bottools.strings.noauth)
|
message.reply_text(bottools.strings.noauth)
|
||||||
|
|
||||||
|
@ -288,7 +305,7 @@ def reply(bot, update, args):
|
||||||
try:
|
try:
|
||||||
reply = bottools.methods.getTweetID(args[0], update.message.chat_id)
|
reply = bottools.methods.getTweetID(args[0], update.message.chat_id)
|
||||||
two = bottools.methods.getTwo(update.message)
|
two = bottools.methods.getTwo(update.message)
|
||||||
otweet = twitools.getTweet(reply)
|
otweet = two.getTweet(reply)
|
||||||
sender = otweet.user.screen_name
|
sender = otweet.user.screen_name
|
||||||
|
|
||||||
if not ("@%s" % sender.strip("@")) in [("@%s" % a.strip("@")) for a in args]:
|
if not ("@%s" % sender.strip("@")) in [("@%s" % a.strip("@")) for a in args]:
|
||||||
|
@ -329,7 +346,7 @@ def quote(bot, update, args):
|
||||||
try:
|
try:
|
||||||
reply = bottools.methods.getTweetID(args[0], update.message.chat_id)
|
reply = bottools.methods.getTweetID(args[0], update.message.chat_id)
|
||||||
two = bottools.methods.getTwo(update.message)
|
two = bottools.methods.getTwo(update.message)
|
||||||
otweet = twitools.getTweet(reply)
|
otweet = two.getTweet(reply)
|
||||||
sender = otweet.user.screen_name
|
sender = otweet.user.screen_name
|
||||||
|
|
||||||
args += ["https://twitter.com/%s/status/%i" % (sender, int(reply))]
|
args += ["https://twitter.com/%s/status/%i" % (sender, int(reply))]
|
||||||
|
@ -358,6 +375,7 @@ def retweet(bot, update, args):
|
||||||
def thread(bot, update, args):
|
def thread(bot, update, args):
|
||||||
message = update.message or update.callback_query.message
|
message = update.message or update.callback_query.message
|
||||||
tid = bottools.methods.getTweetID(args[0], message.chat_id)
|
tid = bottools.methods.getTweetID(args[0], message.chat_id)
|
||||||
|
two = getTwo(message.chat_id)
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
|
|
||||||
|
@ -366,13 +384,13 @@ def thread(bot, update, args):
|
||||||
except:
|
except:
|
||||||
count = 5
|
count = 5
|
||||||
|
|
||||||
tweets = [twitools.getTweet(tid)]
|
tweets = [two.getTweet(tid)]
|
||||||
|
|
||||||
if tweets[-1].in_reply_to_status_id:
|
if tweets[-1].in_reply_to_status_id:
|
||||||
nexttid = tweets[-1].in_reply_to_status_id
|
nexttid = tweets[-1].in_reply_to_status_id
|
||||||
|
|
||||||
while i < count:
|
while i < count:
|
||||||
tweets += [twitools.getTweet(nexttid)]
|
tweets += [two.getTweet(nexttid)]
|
||||||
if not tweets[-1].in_reply_to_status_id:
|
if not tweets[-1].in_reply_to_status_id:
|
||||||
break
|
break
|
||||||
nexttid = tweets[-1].in_reply_to_status_id
|
nexttid = tweets[-1].in_reply_to_status_id
|
||||||
|
@ -460,7 +478,7 @@ def tweetMessage(status, cid, bot, force = False, callback = None, notified = No
|
||||||
ase = db.aseByAto(notified)
|
ase = db.aseByAto(notified)
|
||||||
oac = twitools.twObject(ato=notified, ase=ase).whoami()
|
oac = twitools.twObject(ato=notified, ase=ase).whoami()
|
||||||
|
|
||||||
header = [telegram.InlineKeyboardButton(bottools.strings.messageSwitch % oac, callback_data = "/switch %s" % oac)]
|
header = [telegram.InlineKeyboardButton(bottools.strings.messageSwitch % oac, callback_data = "/switch %s %i" % (oac, i))]
|
||||||
|
|
||||||
if status.favorited:
|
if status.favorited:
|
||||||
buttons += [telegram.InlineKeyboardButton("Unlike", callback_data = "/unlike %i" % i)]
|
buttons += [telegram.InlineKeyboardButton("Unlike", callback_data = "/unlike %i" % i)]
|
||||||
|
|
|
@ -111,6 +111,10 @@ class dbObject:
|
||||||
self.executeQuery("DELETE FROM tokens WHERE cid = %i AND active;" % int(cid))
|
self.executeQuery("DELETE FROM tokens WHERE cid = %i AND active;" % int(cid))
|
||||||
self.commit()
|
self.commit()
|
||||||
|
|
||||||
|
def deleteUserByAto(self, ato):
|
||||||
|
self.executeQuery("DELETE FROM tokens WHERE ato = '%s';" % ato)
|
||||||
|
self.commit()
|
||||||
|
|
||||||
def storeUser(self, cid, ato, ase):
|
def storeUser(self, cid, ato, ase):
|
||||||
self.executeQuery("UPDATE tokens SET active = 0 WHERE cid = %i;" % int(cid))
|
self.executeQuery("UPDATE tokens SET active = 0 WHERE cid = %i;" % int(cid))
|
||||||
self.executeQuery("UPDATE tokens SET ato = '%s', ase = '%s', active = 1 WHERE cid = %i AND ase IS NULL;" % (ato, ase, int(cid)))
|
self.executeQuery("UPDATE tokens SET ato = '%s', ase = '%s', active = 1 WHERE cid = %i AND ase IS NULL;" % (ato, ase, int(cid)))
|
||||||
|
|
Loading…
Reference in a new issue