SHOW:
|
|
- or go back to the newest paste.
| 1 | chanQueue = [] ; channels = [] | |
| 2 | users = {
| |
| 3 | "Aha2Y!DutchFag": "admin" | |
| 4 | } | |
| 5 | ||
| 6 | ||
| 7 | s = socket.socket ( socket.AF_INET, socket.SOCK_STREAM ) | |
| 8 | s.connect ( ( host, port) ) | |
| 9 | s.send ( 'NICK %s\r\n' % botnick) | |
| 10 | s.send ( 'USER znc bot znc :znc\r\n') | |
| 11 | ||
| 12 | ||
| 13 | while True: | |
| 14 | data = s.recv ( 4096 ) | |
| 15 | raw = data.split() | |
| 16 | print data | |
| 17 | nick = data.split('!')[0][1:]
| |
| 18 | sender = data.split('@')[0][1:]
| |
| 19 | if data.find ( 'PING' ) != -1: | |
| 20 | s.send ( 'PONG ' + data.split() [ 1 ] + '\r\n' ) | |
| 21 | if data.find ( 'You need to send your password. Try /quote PASS <username>:<password>' ) != -1: | |
| 22 | s.send ('PASS %s \r\n' % zncauth)
| |
| 23 | if data.split()[1] == 'JOIN': | |
| 24 | channels.append(data.split()[2][:1]) | |
| 25 | if data.find ( '!uptime' ) != -1: | |
| 26 | chanQueue.append(data.split()[2]) | |
| 27 | s.send('PRIVMSG *STATUS :uptime\r\n')
| |
| 28 | if data.find ( '[email protected] PRIVMSG %s :Running for' % botnick) != -1: | |
| 29 | channel = chanQueue[0]; del chanQueue[0] | |
| 30 | days = raw[5].lstrip('d')
| |
| 31 | hours = raw[6] | |
| 32 | minuts = raw[7] | |
| 33 | seconds = raw[8] | |
| 34 | s.send('PRIVMSG %s :The bouncer is up for %s %s %s %s!\r\n' % (channel, days, hours, minuts, seconds))
| |
| 35 | if data.find ( '!global' ) != -1: | |
| 36 | try: | |
| 37 | if users[str(sender)]: | |
| 38 | if len(raw) != 4: | |
| 39 | chanQueue.append(data.split()[2]) | |
| 40 | globalmessage = raw[4:] | |
| 41 | message = ' '.join(globalmessage) | |
| 42 | s.send('PRIVMSG *status :broadcast [Global] %s\r\n' % message)
| |
| 43 | except KeyError: | |
| 44 | s.send('notice %s :You are not a admin.\r\n' % nick)
| |
| 45 | if data.find ( '!rehash' ) != -1: | |
| 46 | try: | |
| 47 | if users[str(sender)]: | |
| 48 | if len(raw) == 4: | |
| 49 | s.send('PRIVMSG *STATUS :rehash\r\n')
| |
| 50 | s.send('PRIVMSG %s :Rehashed the bouncer.\r\n' % raw[2])
| |
| 51 | except KeyError: | |
| 52 | s.send('notice %s :You are not a admin.\r\n' % nick)
| |
| 53 | if data.find ( '!help' ) != -1: | |
| 54 | if len(raw) == 4: | |
| 55 | s.send('PRIVMSG %s :Available public commands: !uptime\n' % raw[2])
| |
| 56 | s.send('PRIVMSG %s :Available admin commands: !global, !rehash\n' % raw[2])
| |
| 57 | if data.find ( '!test' ) != -1: | |
| 58 | if len(raw) == 4: | |
| 59 | s.send('PRIVMSG %s :%s\n' % (channel, sender))
| |
| 60 | if data.find ( ':*** [Global]' ) != -1: | |
| 61 | globalmessage = raw[4:] | |
| 62 | channel = chanQueue[0]; del chanQueue[0] | |
| 63 | message = ' '.join(globalmessage) | |
| 64 | s.send('PRIVMSG %s :%s\r\n' % (channels, message)) |