首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >telegram-bot python | TypeError: mute()缺少一个必需的位置参数:'args‘

telegram-bot python | TypeError: mute()缺少一个必需的位置参数:'args‘
EN

Stack Overflow用户
提问于 2020-08-14 01:29:10
回答 1查看 360关注 0票数 0

我正在创建一个im创建一个使用python的电报机器人,并且我已经创建了一个函数,该函数通过另一个用户的回复来获取原始消息的用户id……

让我解释一下,

在电报组中有A和B的情况下,

答:“嗨”

B:标签/通过"/info“回复A的"hi”

在这种情况下,我需要知道组中的机器人如何通过B给出(回复)的"/info“获取A的信息?

所以我写了一段代码来检查:

代码语言:javascript
复制
import logging
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters

from typing import Optional, List

from telegram import Message, Chat, Update, Bot, User
from telegram.error import BadRequest
from telegram.ext.dispatcher import run_async
from telegram.utils.helpers import mention_html


updater = Updater("1262215479:AAHtwK5J-6lP8iw9b7uRjcOaazelRkHgq3s", use_context=True)
dp = updater.dispatcher


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

logger = logging.getLogger(__name__)


def mute(bot: Bot, update: Update, args):
    chat = update.effective_chat  # type: Optional[Chat]
    user = update.effective_user  # type: Optional[User]
    message = update.effective_message  # type: Optional[Message]
    user_id = extract_user(message, args)
    member = chat.get_member(int(user_id))
    print("hey1")


def main():
    
    dp.add_handler(CommandHandler("promote", mute))

    updater.start_polling()

    updater.idle()


if __name__ == '__main__':
    main()

我得到'TypeError: mute() missing 1个必需的位置参数:'args'‘错误

EN

回答 1

Stack Overflow用户

发布于 2021-03-24 03:11:01

你得到一个错误的原因是args需要一个参数,但你的意思是带星号的*args

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63400360

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档