我的机器人如何删除组中发送给它的/命令消息?

2024-04-23 17:30:57 发布

您现在位置:Python中文网/ 问答频道 /正文

首先让我先说我不是程序员。你知道吗

我需要一些帮助获得以下代码删除/命令发送到机器人从群聊。你知道吗

不是程序员,把下面的代码和我发现的例子放在一起。你知道吗

谢谢


import telegram
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
from telegram import (ReplyKeyboardMarkup, ReplyKeyboardRemove)
import logging
import time

updater = Updater(token='TOKEN')

dispatcher = updater.dispatcher

logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
                     level=logging.INFO)

def start(bot, update):
        bot.send_message(chat_id=update.message.chat_id, text="Where would you like to go?")
start_handler = CommandHandler('start', start)
dispatcher.add_handler(start_handler)

### lions_park
def lions_park(bot, update):
    bot.send_message(chat_id=update.message.chat_id, text='<b>lions park</b> <a href="https://www.google.com/maps/search/?api=1&query=49.266137,-122.780679"> Take Me There! </a>', parse_mode=telegram.ParseMode.HTML)
lions_park_handler = CommandHandler('lions_park', lions_park)
dispatcher.add_handler(lions_park_handler)

### frog_gym
def frog_gym(bot, update):
    bot.send_message(chat_id=update.message.chat_id, text='<b>frog gym</b> <a href="https://www.google.com/maps/search/?api=1&query=49.299372,-122.760475"> Take Me There! </a>', parse_mode=telegram.ParseMode.HTML)
frog_gym_handler = CommandHandler('frog_gym', frog_gym)
dispatcher.add_handler(frog_gym_handler)

### bee_house
def bee_house(bot, update):
    bot.send_message(chat_id=update.message.chat_id, text='<b>bee house</b> <a href="https://www.google.com/maps/search/?api=1&query=49.286018,-122.784835"> Take Me There! </a>', parse_mode=telegram.ParseMode.HTML)
bee_house_handler = CommandHandler('bee_house', bee_house)
dispatcher.add_handler(bee_house_handler)

updater.start_polling()

Tags: idparkmessagebotchatupdatestarthouse