from vkbottle import Bot import config bot = Bot(tokens=config.TOKEN_BOT) if __name__ == '__main__': from routes import query_timetable, call_schedule, notify, other bot.set_blueprints(call_schedule.bp, notify.bp, other.bp, query_timetable.bp) bot.run_polling()
load_dotenv() token = os.environ.get('TOKEN') bot = Bot(tokens=[token], debug=Config.DEBUG) bot.branch = DBStoredBranch() photo_uploader = PhotoUploader(bot.api, generate_attachment_strings=True) @bot.middleware.middleware_handler() class CheckUserStateMiddleware(Middleware): async def pre(self, msg: Message, *args): if not Config.USE_MIDDLEWARE: return u = await UserState.filter(uid=msg.from_id).get_or_none() if u is None: u = await UserState.create( uid=msg.from_id, branch='main', context={} ) await u.save() if __name__ == '__main__': bot.set_blueprints(mentors.bp, main.bp, news.bp, faq.bp, schedule.bp, main.bp) bot.run_polling( on_startup=init_db )
from vkbottle import Bot, Message from examples.tests.blueprints.plugins import fare_bp, greet_bp import os bot = Bot(tokens=os.environ["TOKEN"], debug="DEBUG") bot.set_blueprints(fare_bp, greet_bp) @bot.on.message_handler(text="Where are the blueprints?") async def wrapper(ans: Message): await ans("They’re on top!") bot.run_polling(skip_updates=True)
from vkbottle import Bot from src.portal.portal_endpoint import bp as portal_bp from src.schedule.schedule_endpoint import bp as schedule_bp from src.groups.groups import bp as groups_bp from src.transport.endpoint import bp as trams_bp import os API_TOKEN = os.environ['API_TOKEN'] bot = Bot(API_TOKEN) bot.set_blueprints(portal_bp, schedule_bp, groups_bp, trams_bp)