This commit is contained in:
机器人总动员 2021-05-05 11:10:01 +08:00
parent 14e8e7f627
commit 3a3e2bb35c
3 changed files with 33 additions and 20 deletions

30
func.py Normal file
View File

@ -0,0 +1,30 @@
import datetime
import threading
import telegram
from telegram import InlineKeyboardMarkup, InlineKeyboardButton, ForceReply
from telegram.ext import CommandHandler, MessageHandler, Filters, ConversationHandler, CallbackQueryHandler
from config import TOKEN
import sqlite3
import time
import os
import importlib
import requests
bot = telegram.Bot(token=TOKEN)
def start(update, context):
print('进入start函数')
update.message.reply_text(
'您好!',
)
def chat_content_exec(update, context):
chat_id = update.effective_message.chat_id
print(chat_id)
start_handler = CommandHandler('start', start)
chat_content_handler = MessageHandler(Filters.text, chat_content_exec),

21
main.py
View File

@ -2,30 +2,13 @@ from telegram.ext import Updater
from config import TOKEN
from telegram import InlineKeyboardMarkup, InlineKeyboardButton, ForceReply
from telegram.ext import CommandHandler, MessageHandler, Filters, ConversationHandler, CallbackQueryHandler
import sqlite3
from func import start, reserve, run, kill, status, update, get
from func import start_handler, chat_content_handler
updater = Updater(token=TOKEN, use_context=True)
dispatcher = updater.dispatcher
start_handler = CommandHandler('start', start)
reserve_handler = CommandHandler('reserve', reserve)
run_handler = CommandHandler('run', run)
kill_handler = CommandHandler('kill', kill)
update_handler = CommandHandler('update', update)
status_handler = CommandHandler('status', status)
get_handler = CommandHandler('get', get)
dispatcher.add_handler(start_handler)
dispatcher.add_handler(reserve_handler)
dispatcher.add_handler(run_handler)
dispatcher.add_handler(kill_handler)
dispatcher.add_handler(update_handler)
dispatcher.add_handler(status_handler)
dispatcher.add_handler(get_handler)
dispatcher.add_handler(chat_content_handler)
updater.start_polling()
updater.idle()