コード例 #1
0
import vkbot

bot = vkbot.VkBot()
bot.run()
コード例 #2
0
ファイル: inf.py プロジェクト: rezvorck/vkbot
    bot.dump()
    logging.shutdown()
    sys.exit()

def getNameIndex(name):
    names = open('data/names.txt', encoding='utf-8').readlines()
    for i, n in enumerate(names):
        if name.upper() in n.upper().split():
            return i
    return -1

signal.signal(signal.SIGTERM, onExit)
signal.signal(signal.SIGINT, onExit)

includeread_interval = config.get('intervals.includeread', 'i')
vk = vkbot.VkBot(login, password, includeread_interval)
bot = CppBot(getNameIndex(vk.vars['name'][0]), config.get('vkbot.max_smiles', 'i'), accounts.getFile('chatdump.dat'))
vk.bad_conf_title = lambda s: getBotReplyFlat(' ' + s)

logging.info('I am {}, {}'.format(vk.vars['name'][0], vk.self_id))
banign = BanManager(accounts.getFile('banned.txt'))
vk.banned = banign.banned
if args['whitelist']:
    vk.whitelist = [vk.getUserId(i) or i for i in args['whitelist'].split(',')]
    logging.info('Whitelist: ' + ', '.join(map(lambda x: x if isinstance(x, str) else vk.printableName(x, user_fmt='{name}'), vk.whitelist)))

addfriends_interval = config.get('intervals.addfriends', 'i')
setonline_interval = config.get('intervals.setonline', 'i')
unfollow_interval = config.get('intervals.unfollow', 'i')
filtercomments_interval = config.get('intervals.filtercomments', 'i')
stats_interval = config.get('intervals.stats', 'i')
コード例 #3
0
                         'scope': ['friends'],
                         'response_type': 'token'
                     }).url)
    exit(0)


if __name__ == '__main__':
    # get_url_for_token()

    dotenv_path = os.path.join(os.path.dirname(__file__), '.env')
    if os.path.exists(dotenv_path):
        load_dotenv(dotenv_path)

    community_token = os.environ.get("FULL_TOKEN")
    group_id = os.environ.get("GROUP_ID")
    user_token = os.environ.get('USER_TOKEN')
    db_user = os.environ.get('DATABASE_USER')
    db_password = os.environ.get('DATABASE_PASSWORD')
    db_host = os.environ.get('DATABASE_HOST')
    db_port = os.environ.get('DATABASE_PORT')
    db_name = os.environ.get('DATABASE_NAME')

    bot = vkbot.VkBot(community_token, group_id)
    requester = VkRequester(token=user_token)

    @bot.message_handler(func=lambda m: True)
    def echo_all(message):
        bot.reply_to(message, message.text)

    bot.polling()