Skip to content

Instantly share code, notes, and snippets.

@Canorus
Created February 11, 2020 06:59
Show Gist options
  • Save Canorus/cee25ecff2034c3c098f4319a85a1037 to your computer and use it in GitHub Desktop.
Save Canorus/cee25ecff2034c3c098f4319a85a1037 to your computer and use it in GitHub Desktop.
Feb 11 15:34:54 canors_ubuntu python3[9980]: [2020-02-11 15:34:54,686][DEBUG|teleg.py:112] >> canor searching for: {my query here}
Feb 11 15:46:20 canors_ubuntu python3[9980]: [2020-02-11 15:46:20,496][DEBUG|teleg.py:30] >> <telegram.ext.callbackcontext.CallbackContext object at 0x7fe1fb118ef0>
Feb 11 15:46:23 canors_ubuntu python3[9980]: [2020-02-11 15:46:23,987][DEBUG|teleg.py:112] >> canor searching for: {my query here}
Feb 11 15:46:36 canors_ubuntu python3[9980]: [2020-02-11 15:46:36,427][DEBUG|teleg.py:112] >> canor searching for: {my query here}
Feb 11 15:47:38 canors_ubuntu systemd[1]: Stopping Case detail Telegram bot...
Feb 11 15:47:38 canors_ubuntu systemd[1]: Stopped Case detail Telegram bot.
Feb 11 15:47:38 canors_ubuntu systemd[1]: Started Case detail Telegram bot.
Feb 11 15:47:40 canors_ubuntu python3[27903]: starting telegram bot
Feb 11 15:47:43 canors_ubuntu python3[27903]: [2020-02-11 15:47:43,647][DEBUG|teleg.py:30] >> <telegram.ext.callbackcontext.CallbackContext object at 0x7f2733632eb8>
Feb 11 15:47:45 canors_ubuntu python3[27903]: [2020-02-11 15:47:45,504][DEBUG|teleg.py:30] >> <telegram.ext.callbackcontext.CallbackContext object at 0x7f2733632668>
Feb 11 15:47:47 canors_ubuntu python3[27903]: [2020-02-11 15:47:47,324][DEBUG|teleg.py:30] >> <telegram.ext.callbackcontext.CallbackContext object at 0x7f2733632a90>
Feb 11 15:47:52 canors_ubuntu python3[27903]: [2020-02-11 15:47:52,263][DEBUG|teleg.py:112] >> canor searching for: {my query here}
Feb 11 15:47:55 canors_ubuntu python3[27903]: [2020-02-11 15:47:55,194][DEBUG|teleg.py:115] >> result: []# code should return values like this or on line 15 but it didn't on line 3 and for
Feb 11 15:48:04 canors_ubuntu python3[27903]: [2020-02-11 15:48:04,340][DEBUG|teleg.py:112] >> canor searching for: {my query here}
Feb 11 15:48:07 canors_ubuntu python3[27903]: [2020-02-11 15:48:07,174][DEBUG|teleg.py:115] >> result: [('동부지법', '', '{my query here}', '2020.03.18', '16:00', '제408호법정[4번 출입구 법정동]'), ('북부지법', '', '{my query here}', '2020.03.19', '11:10', '제501호법정'), ('', '강동경찰서 경제4팀 ', '{my query here}', '', '', ''), ('', '서울강동경찰서', '{my query here}', '', '', '')]
def search_callback(update, context):
name = ' '.join(context.args)
user_id = update.effective_user.id
username = update.effective_user.username
if is_registered(user_id) or user_id == admin_user_id:
logger.debug(f'{username} searching for: {name}')
context.bot.send_message(chat_id=update.effective_chat.id, text='잠시만요 찾아볼게요')
ans = gsheet.search(name)
logger.debug(f'result: {ans}') # it will show returned values
if len(ans): # code will return if there's something in the list
for an in ans:
court, case, name, date, time, room = an
rep_text = f'법원: {court}\n사건번호: {case}\n당사자: {name}\n기일: {date}\n시각: {time}\n장소: {room}'
context.bot.send_message(chat_id=update.effective_chat.id, text=rep_text)
else:
rep_text = '입력하신 값을 찾을 수 없습니다.'
context.bot.send_message(chat_id=update.effective_chat.id, text=rep_text)
else:
context.bot.send_message(chat_id=update.effective_chat.id, text='인증 후 사용해주세요 /register')
def kill_callback(update, context):
updater.stop()
updater = Updater(token=mytoken, use_context=True)
updater.dispatcher.add_handler(MessageHandler(Filters.text, repeat))
updater.dispatcher.add_handler(CommandHandler('register',register))
updater.dispatcher.add_handler(CommandHandler('alive', alive_callback))
updater.dispatcher.add_handler(CommandHandler('search', search_callback))
updater.dispatcher.add_handler(CommandHandler('auth', auth))
updater.dispatcher.add_handler(CommandHandler('stop',kill_callback))
updater.start_polling(timeout=10, clean=True)
#updater.idle()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment