Python config.token() Examples

The following are 5 code examples of config.token(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module config , or try the search function .
Example #1
Source File: bot.py    From TweenRoBot with MIT License 6 votes vote down vote up
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']) 
Example #2
Source File: __main__.py    From discord.py with MIT License 5 votes vote down vote up
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) 
Example #3
Source File: bot.py    From TweenRoBot with MIT License 5 votes vote down vote up
def tostick(m):
    cid = m.chat.id
    if m.reply_to_message:
      if m.reply_to_message.sticker:
        token = config.token
        fileid = m.reply_to_message.sticker.file_id
        path1 = bot.get_file(fileid)
        path = path1.file_path
        link = "https://api.telegram.org/file/bot{}/{}".format(token,path)
        urllib.urlretrieve(link, "stick1.png")
        file1 = open('stick1.png', 'rb')
        bot.send_photo(cid,file1)
    
################################################################################################################################################################################################# 
Example #4
Source File: bot.py    From TweenRoBot with MIT License 5 votes vote down vote up
def tostick(message):
    cid = message.chat.id
    banlist = redis.sismember('banlist', '{}'.format(message.from_user.id))
    if str(banlist) == 'False':
      if message.reply_to_message:
        if message.reply_to_message.sticker:
          token = config.token
          file_id = message.reply_to_message.sticker.file_id
          id = message.from_user.id
          redis.hset('stickers',id,file_id)
          bot.send_message(message.chat.id, '<code>Seted :)</code>',parse_mode='HTML')

################################################################################################################################################################################################# 
Example #5
Source File: bot.py    From TweenRoBot with MIT License 5 votes vote down vote up
def tostick(message):
    cid = message.chat.id
    banlist = redis.sismember('banlist', '{}'.format(message.from_user.id))
    if str(banlist) == 'False':
      if message.reply_to_message:
        if message.reply_to_message.photo:
          token = config.token
          file_id = message.reply_to_message.photo[1].file_id
          id = message.from_user.id
          text = message.text.replace("/cap ","")
          redis.hset('caption',id,file_id)
          photo = redis.hget('caption',id)
          bot.send_photo(message.chat.id,photo,caption="{}".format(text))

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