if message.from_id == "баланс":
if "баланс" == message.text:
return f" Ваш баланс: {user.money} монет!"
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
import vk_api
token = "********"
group_id = "********"
vk_session = vk_api.VkApi(token = token)
longpoll = VkBotLongPoll(vk_session, group_id)
vk = vk_session.get_api()
def main():
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW and event.from_chat:
user_id = event.message.from_id
if "-" in str(user_id):
pass
else:
chat(event)
def chat(event):
user_id = event.message.from_id
chat_id = event.message.peer_id % 2000000000
user_info = vk.users.get(user_ids=user_id)
user_info = user_info[0]
first_name = user_info["first_name"]
id = event.chat_id
vk.messages.send(
message= (f"@id{user_id} ({first_name}), СООБЩЕНИЕ"),
chat_id=chat_id,
random_id= 0
)
if __name__ == '__main__':
main()
import schedule
import time
from vk_api import VkApi
from threading import Thread
from vkbottle import Bot, load_blueprints_from_package
TOKEN = "******" #сообщества
vk_session = VkApi(token=TOKEN)
vk = vk_session.get_api()
bot = Bot(TOKEN)
for bp in load_blueprints_from_package("blueprints"):
bp.load(bot)
def main_loop():
thread = Thread(target=do_schedule)
thread.start()
def NAME():
vk.messages.send(
message ="TEXT",
chat_id = chat_id, # Если нужно выслать в чат
#peer_id = user_id, # Если нужно выслать в ЛС
random_id=0)
def do_schedule():
schedule.every().day.at("03:53").do(NAME)
while True:
schedule.run_pending()
time.sleep(1)
if __name__ == '__main__':
main_loop()
bot.run_forever()