當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。