当前位置: 首页>>代码示例>>Python>>正文


Python config.token方法代码示例

本文整理汇总了Python中config.token方法的典型用法代码示例。如果您正苦于以下问题:Python config.token方法的具体用法?Python config.token怎么用?Python config.token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在config的用法示例。


在下文中一共展示了config.token方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: tostick

# 需要导入模块: import config [as 别名]
# 或者: from config import token [as 别名]
def tostick(m):
    cid = m.chat.id
    if m.reply_to_message:
      if m.reply_to_message.photo:
        token = config.token
        fileid = m.reply_to_message.photo[1].file_id
        path1 = bot.get_file(fileid)
        path = path1.file_path
        link = "https://api.telegram.org/file/bot{}/{}".format(token,path)
        urllib.urlretrieve(link, "stick.png")
        file1 = open('stick.png', 'rb')
        bot.send_sticker(cid,file1)

#################################################################################################################################################################################################

#bot.message_handler(commands=['clac']) 
开发者ID:ThisIsAmir,项目名称:TweenRoBot,代码行数:18,代码来源:bot.py

示例2: newbot

# 需要导入模块: import config [as 别名]
# 或者: from config import token [as 别名]
def newbot(parser, args):
    new_directory = to_path(parser, args.directory) / to_path(parser, args.name)

    # as a note exist_ok for Path is a 3.5+ only feature
    # since we already checked above that we're >3.5
    try:
        new_directory.mkdir(exist_ok=True, parents=True)
    except OSError as exc:
        parser.error('could not create our bot directory ({})'.format(exc))

    cogs = new_directory / 'cogs'

    try:
        cogs.mkdir(exist_ok=True)
        init = cogs / '__init__.py'
        init.touch()
    except OSError as exc:
        print('warning: could not create cogs directory ({})'.format(exc))

    try:
        with open(str(new_directory / 'config.py'), 'w', encoding='utf-8') as fp:
            fp.write('token = "place your token here"\ncogs = []\n')
    except OSError as exc:
        parser.error('could not create config file ({})'.format(exc))

    try:
        with open(str(new_directory / 'bot.py'), 'w', encoding='utf-8') as fp:
            base = 'Bot' if not args.sharded else 'AutoShardedBot'
            fp.write(bot_template.format(base=base, prefix=args.prefix))
    except OSError as exc:
        parser.error('could not create bot file ({})'.format(exc))

    if not args.no_git:
        try:
            with open(str(new_directory / '.gitignore'), 'w', encoding='utf-8') as fp:
                fp.write(gitignore_template)
        except OSError as exc:
            print('warning: could not create .gitignore file ({})'.format(exc))

    print('successfully made bot at', new_directory) 
开发者ID:Rapptz,项目名称:discord.py,代码行数:42,代码来源:__main__.py


注:本文中的config.token方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。