Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __author__ = "byStarTW"
- import telepot # pip install telepot
- import time
- import os
- if os.name == "nt":
- os.system ('cls')
- os.system ('title Telegram Bot 訊息傳送')
- else:
- os.system ('clear')
- # settings
- token = ('') # your bot token! (@botfather)
- bot = telepot.Bot(token)
- def sendMessage(chat_id, message):
- bot.sendMessage(chat_id, message)
- def sendMessage_markdown(chat_id, message):
- bot.sendMessage(chat_id, message, 'markdown')
- chat_id = str('') # chat_id
- # confim settings
- if chat_id == (''):
- print ("未設定 chat_id")
- exit()
- if token == (''):
- print ("未設定 TG token")
- exit()
- # Main Menu
- msgMode = input("請輸入輸出文字模式 (Plain Text / Markdown): ")
- if msgMode == "Plain Text":
- msgMode = "False"
- elif msgMode == "Markdown":
- msgMode = "True"
- else:
- exit()
- msgText = input("請輸入輸出的文字: ")
- if msgText != "":
- msgText2 = input("你確定要輸出 '" + msgText + "' 嗎? (Yes / No): " )
- if msgText2 == "Yes":
- if msgMode == "False":
- print ("請稍候... 正在傳送訊息... ")
- sendMessage(chat_id, msgText)
- print ("已經傳送! :-)")
- elif msgMode == "True":
- print ("請稍候... 正在傳送訊息... ")
- sendMessage_markdown(chat_id, msgText)
- print ("已經傳送! :-)")
- else:
- exit()
- else:
- exit()
- else:
- exit()
Advertisement
Add Comment
Please, Sign In to add comment