Created
March 30, 2017 09:35
-
-
Save solyard/197b9517a3a8569ecb9757e8d6f3f35a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def show_q(bot, update): | |
x = update.message.text.split(' ') | |
print(x) | |
if len(x) <= 1 or len(x) > 3: | |
print('FALSE') | |
else: | |
if x[0] == '!!qq': | |
try: | |
k = int(x[1]) | |
except (ValueError, IndexError): | |
k = '1' | |
try: | |
print(update) | |
c.execute("SELECT * FROM quests WHERE id = ?", [str(k)]) | |
keys = ['id','date','username','qtext','rate'] | |
db_lst = OrderedDict(zip(keys, *c.fetchall())) | |
txt = ('*Цитата № {id} * от _{date}_ by _{username}_:\n\n({username}) \n{qtext} \n\n*Рейтинг цитаты [{rate}]*\n /Like /Dislike'.format(**db_lst)) | |
bot.sendMessage(chat_id=update.message.chat_id, text=txt, parse_mode=mdparse) | |
except IndexError: | |
bot.sendMessage(chat_id=update.message.chat_id, text='Цитата не найдена!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment