-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample_bot.py
79 lines (60 loc) · 1.8 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
###########
# Imports #
###########
import warnings
import config
import megach
megach.debug = False
if megach.debug is True:
warnings.simplefilter("always")
#################
# RoomManager #
#################
class ExampleBot(megach.RoomManager):
def onInit(self):
# Auto Start.
config.Tools.auto_start(self)
# Automatic tasks
self.setInterval(900, config.Tools.auto_tasks)
def onStop(self):
# Close bot.
config.Tools.stop_bot(self)
def on_message(self, context):
# Print message.
config.StylePrint.safe_print_bot(
self, context.room,
context.user, context.message, ""
)
# Do cmd or auto answer.
config.Tools.answer_pm_rooms(
self, context.room,
context.user, context.message
)
def onPMMessage(self, pm, user, message):
# Print message.
status = config.Database.take_lang_bot(
config.Bot.bot_lang,
"on_pm_message_online"
)
config.StylePrint.safe_print_bot(self, pm, user, message, status)
# Do cmd or auto answer.
config.Tools.answer_pm_rooms(self, pm, user, message)
def onPMOfflineMessage(self, pm, user, message):
# Print message.
status = config.Database.take_lang_bot(
config.Bot.bot_lang,
"on_pm_message_offline"
)
config.StylePrint.safe_print_bot(self, pm, user, message, status)
def onPMMessageSend(self, pm, user, message):
# Print message.
status = config.Database.take_lang_bot(
config.Bot.bot_lang,
"on_pm_message_send"
)
config.StylePrint.safe_print_bot(self, pm, user, message, status)
#######
# End #
#######