美文网首页
机器人使用方法

机器人使用方法

作者: _Haimei | 来源:发表于2018-07-23 12:29 被阅读24次

/start
@gif – GIF search
@vid – Video search
@pic – Yandex image search
@bing – Bing image search
@wiki – Wikipedia search
@imdb – IMDB search
@bold – Make bold, italic or fixed sys text
@youtube - Connect your account for personalized results
@music - Search and send classical music
@foursquare – Find and send venue addresses
@sticker – Find and send stickers based on emoji

test.py测试文件

import telegram
from telegram.ext import Updater
import logging
from telegram.ext import CommandHandler
from telegram.ext import MessageHandler, Filters
from telegram import InlineQueryResultArticle, InputTextMessageContent
from telegram.ext import InlineQueryHandler
bot = telegram.Bot(token = 'token值')
print(bot.get_me())
updater = Updater(token='token值')
dispatcher = updater.dispatcher
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',level=logging.INFO)



#这是/start部分
def start(bot, update):
    bot.send_message(chat_id=update.message.chat_id, text="I'm a bot, please talk to me!")
start_handler = CommandHandler('start', start)
dispatcher.add_handler(start_handler)
updater.start_polling()


def echo(bot, update):
    bot.send_message(chat_id=update.message.chat_id, text=update.message.text)
echo_handler = MessageHandler(Filters.text, echo)
dispatcher.add_handler(echo_handler)


def caps(bot, update, args):
    text_caps = ' '.join(args).upper() 
    bot.send_message(chat_id=update.message.chat_id, text=text_caps)
caps_handler = CommandHandler('caps', caps, pass_args=True)
dispatcher.add_handler(caps_handler)


def inline_caps(bot, update):
    query = update.inline_query.query
    if not query:
        return
    results = list()
    results.append(
        InlineQueryResultArticle(
            id=query.upper(),
            title='Caps',
            input_message_content=InputTextMessageContent(query.upper())
        )
    )
    bot.answer_inline_query(update.inline_query.id, results)
inline_caps_handler = InlineQueryHandler(inline_caps)
dispatcher.add_handler(inline_caps_handler)


def unknown(bot, update):
    bot.send_message(chat_id=update.message.chat_id, text="Sorry, I didn't understand that command.")
unknown_handler = MessageHandler(Filters.command, unknown)
dispatcher.add_handler(unknown_handler)


def reply(bot, update):
    bot.send_chat_action(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
reply_handler = CommandHandler('reply', reply)
dispatcher.add_handler(reply_handler)

# updater.stop()

相关文章

  • 伯爵机器人是干什么的?

    本文介绍 伯爵返利机器人使用方法简介 伯爵返利机器人使用方法简介 本文由在当地较为英俊的男子金天大神原创,版权所有...

  • 机器人使用方法

    /start@gif – GIF search@vid – Video search@pic – Yandex i...

  • 返利机器人使用方法

    操作步骤 打开手机淘宝,选你要买的宝贝 点击分享到微信 分享链接给返利机器人 进入机器人返回的链接,复制淘宝的口令...

  • 3月27日小步子

    1、带着闺女出去逛了一下,进行了很好的互动。 2、和姨夫沟通扫地机器人的使用方法,开始启动并使用,协助他们体验这个...

  • 『小喵』机器人基本使用方法

    助手支持淘宝、京东、拼多多优惠查询,通过小喵链接购买的宝贝,小喵会自动跟单进行返利 【淘宝】查询方法 ① 打开宝贝...

  • React 中,ref 的常用方法

    使用方法一 使用方法二 使用方法三: createRef

  • 说明哦

    点我查看使用方法 点我查看使用方法 点我查看使用方法

  • 2019年使用说明

    点我查看使用方法 点我查看使用方法 点我查看使用方法

  • NSTimer 定时器简单用法

    一、初始化方法:有五种初始化方法,分别是 使用方法: 使用方法: 使用方法: 使用方法: 使用方法: 注意:这五种...

  • 2018年最新电话号码正则表达式校验方法

    正则表达式 iOS使用方法 Android使用方法: java使用方法:

网友评论

      本文标题:机器人使用方法

      本文链接:https://www.haomeiwen.com/subject/qwodmftx.html