{"id":837,"date":"2019-12-27T18:09:31","date_gmt":"2019-12-27T09:09:31","guid":{"rendered":"http:\/\/blog.marubaram.wo.tc\/?p=837"},"modified":"2019-12-27T18:09:31","modified_gmt":"2019-12-27T09:09:31","slug":"%ec%8b%9c%eb%86%80%eb%a1%9c%ec%a7%80-python-telegram-bot-%eb%a7%8c%eb%93%a4%ea%b8%b0-%eb%a9%94%ec%84%b8%ec%a7%80-%ec%9d%91%eb%8b%b5-message-handler","status":"publish","type":"post","link":"https:\/\/blog.marubaram.wo.tc\/?p=837","title":{"rendered":"\uc2dc\ub180\ub85c\uc9c0 Python Telegram Bot \ub9cc\ub4e4\uae30: \uba54\uc138\uc9c0 \uc751\ub2f5 Message Handler"},"content":{"rendered":"\n<p>\uba54\uc138\uc9c0\uc5d0 \uc751\ub2f5\ud558\ub3c4\ub85d \ucf54\ub4dc\ub97c \uc218\uc815\ud55c\ub2e4. \uba54\uc138\uc9c0 \uc751\ub2f5\uc740 Updater\ub97c \uc774\uc6a9\ud558\uc5ec \uc5c5\ub370\uc774\ud2b8\uac00 \ub418\uba70, CommandHandler \ub098 MessageHandler\uc5d0 \uc758\ud574 \ub3d9\uc791\ud558\uac8c \ub418\ub294 \ub370, \uc6b0\uc120 MessageHandler \uc0ac\uc6a9\ubc95\uc744 \uc815\ub9ac\ud55c\ub2e4.<\/p>\n\n\n\n<p>\uc544\ub798\uc640  \uac19\uc774 \uc6b0\uc120 \ubaa8\ub4c8\uc744 \ubd88\ub7ec\uc628\ub2e4.<\/p>\n\n\n\n<p>from telegram.ext import Updater, MessageHandler, Filters <\/p>\n\n\n\n<p>\uc0c1\ud0dc \uc5c5\ub370\uc774\ud2b8\ub97c \uc704\ud574 \uc544\ub798\uc640 \uac19\uc774 Updater \uc124\uc815\ud55c\ub2e4.<\/p>\n\n\n\n<p>updater = Updater(token = &#8216;TOKEN HERE&#8217;)<\/p>\n\n\n\n<p>\uadf8\ub7f0\ub370 \uc544\ub798\uc640 \uac19\uc740 \uba54\uc138\uc9c0\uac00 \uc790\uafb8 \ub728\uba74\uc11c \ubb38\uc81c\uac00 \ubc1c\uc0dd\ud588\ub2e4. <\/p>\n\n\n\n<p>ImportError: cannot import name &#8216;Type&#8217;<\/p>\n\n\n\n<p>\ucc3e\uc544\ubcf4\ub2c8, \uc2dc\ub180\ub85c\uc9c0\uc5d0 \ud604\uc7ac \uc124\uce58\ub418\uc5b4 \uc788\ub294 python3 \ub294 3.5.1 \uc778\ub370 Typing \ubaa8\ub4c8\uc774 \uc5c6\ub2e4\uace0 \ud55c\ub2e4.<\/p>\n\n\n\n<p>python3 -m pip install &#8211;user typing <\/p>\n\n\n\n<p>\ub0b4 \uacbd\uc6b0\uc5d0\ub294 \uc704 \ucf54\ub4dc\ub85c \ud574\ub3c4 \ud574\uacb0\uc774 \uc548\ub41c\ub2e4. Tornado \ubc84\uc83c\uc744 \uc544\ub798\uc640 \uac19\uc774 \ub0ae\ucd94\ub2c8 \ub41c\ub2e4.<\/p>\n\n\n\n<p>python3 -m pip install &#8211;user tornado==5.1.1<\/p>\n\n\n\n<p>Message Handler \uad00\ub828\ud558\uc5ec\uc11c\ub294 \uc544\ub798\uc640 \uac19\uc774 \uc124\uc815\ud55c\ub2e4. <br>1) Handler \uac00 \ucc98\ub9ac\ud560 function\uc744 \uc815\uc758<br>2) Handler\uc5d0 function \ub4f1\ub85d<br>3) Updater\uc5d0 Handler \ub4f1\ub85d<br>4) Updater\uac00 \uc5bc\ub9c8\ub098 \uac04\uaca9\uc73c\ub85c \ub3cc\uac8c \ud560\uc9c0 \uc124\uc815<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p> def get_message(bot, update):<br>     update.message.reply_text(&#8216;\uba54\uc138\uc9c0\ub97c \ubc1b\uc558\uc2b5\ub2c8\ub2e4.&#8217;) <br><br>message_handler = MessageHandler(Filters.text, get_message)<br>updater.dispatcher.add_handler(message_handler) <br>updater.start_polling(timeout=3, clean=True)<br>updater.idle() <\/p><\/blockquote>\n\n\n\n<p>\uc798 \ub3cc\uc544\uac04\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uba54\uc138\uc9c0\uc5d0 \uc751\ub2f5\ud558\ub3c4\ub85d \ucf54\ub4dc\ub97c \uc218\uc815\ud55c\ub2e4. \uba54\uc138\uc9c0 \uc751\ub2f5\uc740 Updater\ub97c \uc774\uc6a9\ud558\uc5ec \uc5c5\ub370\uc774\ud2b8\uac00 \ub418\uba70, CommandHandler \ub098 MessageHandler\uc5d0 \uc758\ud574 \ub3d9\uc791\ud558\uac8c \ub418\ub294 \ub370, \uc6b0\uc120 MessageHandler \uc0ac\uc6a9\ubc95\uc744 \uc815\ub9ac\ud55c\ub2e4. \uc544\ub798\uc640 \uac19\uc774 \uc6b0\uc120 \ubaa8\ub4c8\uc744 \ubd88\ub7ec\uc628\ub2e4. from telegram.ext import Updater, MessageHandler, Filters \uc0c1\ud0dc \uc5c5\ub370\uc774\ud2b8\ub97c \uc704\ud574 \uc544\ub798\uc640 \uac19\uc774 Updater \uc124\uc815\ud55c\ub2e4. updater = Updater(token = &#8216;TOKEN HERE&#8217;) \uadf8\ub7f0\ub370 \uc544\ub798\uc640 \uac19\uc740 \uba54\uc138\uc9c0\uac00 \uc790\uafb8 \ub728\uba74\uc11c \ubb38\uc81c\uac00 \ubc1c\uc0dd\ud588\ub2e4. ImportError: cannot [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[336],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.marubaram.wo.tc\/index.php?rest_route=\/wp\/v2\/posts\/837"}],"collection":[{"href":"https:\/\/blog.marubaram.wo.tc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.marubaram.wo.tc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.marubaram.wo.tc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.marubaram.wo.tc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=837"}],"version-history":[{"count":1,"href":"https:\/\/blog.marubaram.wo.tc\/index.php?rest_route=\/wp\/v2\/posts\/837\/revisions"}],"predecessor-version":[{"id":838,"href":"https:\/\/blog.marubaram.wo.tc\/index.php?rest_route=\/wp\/v2\/posts\/837\/revisions\/838"}],"wp:attachment":[{"href":"https:\/\/blog.marubaram.wo.tc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=837"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.marubaram.wo.tc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=837"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.marubaram.wo.tc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=837"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}