forked from Athesdrake/aiotfm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_bot.py
55 lines (36 loc) · 1.01 KB
/
example_bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import asyncio
import json
from aiotfm.client import Client
with open("bot.config") as f:
config = json.load(f)
bot = Client()
boot_time = bot.loop.time()
@bot.event
async def on_login_ready(*a):
print("Logging in ...")
await bot.login(**config)
@bot.event
async def on_ready():
print(f"Connected to the community platform in {bot.loop.time() - boot_time:.2f} seconds")
await bot.enterTribe()
@bot.event
async def on_tribe_inv(author, tribe):
print("tribe invitation received")
await bot.enterInvTribeHouse(author)
@bot.event
async def on_whisper(message):
print(message)
if message.content == "tribe":
await bot.enterTribeHouse()
await message.reply(message.content) # echo
@bot.event
async def on_room_message(message):
print(message)
if message.content == "tribe":
await bot.enterTribeHouse()
@bot.event
async def on_joined_room(room):
print("Joined room:", room)
loop = asyncio.get_event_loop()
loop.create_task(bot.start(config.pop("api_id"), config.pop("api_token")))
loop.run_forever()