Showing
1 changed file
with
44 additions
and
0 deletions
respond.py
0 → 100644
1 | +# https://blog.psangwoo.com/coding/2018/01/09/python-telegram-bot-3.html | ||
2 | + | ||
3 | +from telegram.ext import Updater, MessageHandler, Filters | ||
4 | + | ||
5 | +updater = Updater(token = "1721885449:AAHDGMbjSJfhXxML6nfSCpfiU7SghpL_vOE") | ||
6 | +updater = Updater(token = "1721885449:AAHDGMbjSJfhXxML6nfSCpfiU7SghpL_vOE", use_context=True) | ||
7 | + | ||
8 | +dispatcher = updater.dispatcher | ||
9 | +updater.start_polling() | ||
10 | + | ||
11 | +#def greet_user(`update: Update, context: CallbackContext`): | ||
12 | +def handler(update, context): | ||
13 | + text = update.message.text | ||
14 | + chat_id = update.message.chat_id | ||
15 | + | ||
16 | + if "모해" in text: | ||
17 | + update.message.reply_text("진세 생각 ❤") | ||
18 | + | ||
19 | + elif 'ㅎㅎ' in text: | ||
20 | + update.message.reply_text("ㅎㅎ") | ||
21 | + | ||
22 | + elif '밥 먹었어?' in text: | ||
23 | + update.message.reply_text("나 아직 못 먹었어 ㅠㅠ, 진세는 밥 먹었어?") | ||
24 | + elif '먹었어' in text: | ||
25 | + update.message.reply_text("우왕 뭐 먹었어?") | ||
26 | + elif '안 먹었엉' in text: | ||
27 | + update.message.reply_text("헐헐 어쩌다?, 같이 뭐라도 먹을래?") | ||
28 | + elif '같이 먹자' in text: | ||
29 | + update.message.reply_text("웅웅 집앞으로 나와") | ||
30 | + | ||
31 | + | ||
32 | + elif '사랑해' in text: | ||
33 | + update.message.reply_text("내가 더 사랑해 ❤") | ||
34 | + | ||
35 | + elif '잘자' in text: | ||
36 | + update.message.reply_text("웅웅, 진세 너두 잘자 ㅎㅎ") | ||
37 | + | ||
38 | + else: | ||
39 | + update.message.reply_text("응?") | ||
40 | + | ||
41 | + | ||
42 | +echo_handler = MessageHandler(Filters.text, handler) #업데이터를 통해서 필터된 텍스트가 """핸들러로 전달됨""" | ||
43 | +dispatcher.add_handler(echo_handler) | ||
44 | + |
-
Please register or login to post a comment