Skip to content

Instantly share code, notes, and snippets.

@mr-yoo
Last active December 2, 2017 11:54
Show Gist options
  • Save mr-yoo/b9591ad9d95aef68062e958bc73f6d2f to your computer and use it in GitHub Desktop.
Save mr-yoo/b9591ad9d95aef68062e958bc73f6d2f to your computer and use it in GitHub Desktop.
미래에셋대우 - 2기
import sys
from PyQt5.QtWidgets import *
from PyQt5 import uic
import telepot
from telepot.loop import MessageLoop
form_class = uic.loadUiType("main_window.ui")[0]
class MyWindow(QMainWindow, form_class):
def __init__(self):
super().__init__()
self.setupUi(self)
# 텔레그램 봇 생성
self.bot = telepot.Bot("Paste your private key")
MessageLoop(self.bot, self.handle).run_as_thread()
def handle(self, msg):
content_type, chat_type, chat_id = telepot.glance(msg)
if content_type == 'text':
self.bot.sendMessage(chat_id, msg['text'])
# 메시지 수신 시 ListWidget에 추가
self.recieveListWidget.addItem(msg['text'])
if __name__ == "__main__":
app = QApplication(sys.argv)
mywindow = MyWindow()
mywindow.show()
app.exec_()
@mr-yoo
Copy link
Author

mr-yoo commented Dec 2, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment