forked from jamesmeneghello/pynab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprebot.py
executable file
·56 lines (40 loc) · 1.32 KB
/
prebot.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
"""
Pynab Prebot
Starts a prebot that listens on the #nZEDbPRE channel.
Usage:
prebot.py start
Options:
-h --help Show this screen.
--version Show version.
"""
# Thanks to Joel Rosdahl <[email protected]> for this script
# Taken from https://bitbucket.org/jaraco/irc/src
import string
import random
import irc.bot
import irc.strings
from docopt import docopt
import pynab.pre
from pynab import log_init, log
class TestBot(irc.bot.SingleServerIRCBot):
def __init__(self, channel, nickname, server, port=6667):
irc.bot.SingleServerIRCBot.__init__(self, [(server, port)], nickname, nickname)
self.channel = channel
def on_nicknameinuse(self, c, e):
c.nick(c.get_nickname() + "_")
def on_welcome(self, c, e):
c.join(self.channel)
def on_pubmsg(self, c, e):
a = e.arguments[0]
pynab.pre.nzedbirc(a)
def main():
channel = "#nZEDbPRE"
nickname = ''.join([random.choice(string.ascii_letters) for n in range(8)])
log.info("Pre: Bot Nick - {}".format(nickname))
bot = TestBot(channel, nickname, "irc.synirc.net", 6667)
bot.start()
if __name__ == '__main__':
arguments = docopt(__doc__, version=pynab.__version__)
if arguments['start']:
log_init('prebot')
main()