This repository has been archived by the owner on Apr 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pealbot.py
executable file
·70 lines (55 loc) · 2.04 KB
/
pealbot.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
#!/usr/bin/env python
# coding: utf-8
"""
Copyright (c) 2012 Anton Zering <synth@lostprofile.de>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import os.path
from lib.pybot import BotBot
from lib.plugindispatcher import PluginDispatcher
from lib.tools import Debug
class PealBot(BotBot):
"""
:author: Anton Zering <synth@lostprofile.de>
:author: Julian Held <nemesis@creative-heads.org>
:copyright: 2012, Anton Zering
:license: Apache License, Version 2.0
"""
def __init__(self, config):
BotBot.__init__(self, config.HOST, config.IDENTITY['nick'], config.IDENTITY['realname'])
self.config = config
self.d = Debug()
# initialize PluginDispatcher and autoload modules
self.plugin_dispatcher = PluginDispatcher(self, config.PATHS['plugins'])
self.plugin_dispatcher.load_plugins(config.PLUGINS)
def handle_irc(self, msg):
# handle "built in" event hooks
BotBot.handle_irc(self, msg)
# handle plugin event hooks
self.plugin_dispatcher.handle_irc(msg)
def exit(self, exit_code=0):
"""Invokes the before_unload hook of all loaded plugins before the module gets unloaded."""
# invoke system hook
self.plugin_dispatcher.invoke_all("before_unload")
BotBot.exit(self, exit_code)
def quit(self, quit_reason=''):
"""Invokes the before_quit hook of all loaded plugins before the QUIT message is sent to the server."""
# invoke system hook
self.plugin_dispatcher.invoke_all("before_quit")
BotBot.quit(self, quit_reason)
if __name__ == '__main__':
try:
import config
except:
print "Configuration could not be found."
sys.exit(1)
pb = PealBot(config)
pb.start()