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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
#!/usr/bin/env python
import sys
import socket
import string
import os
import time
import re
import random
import MySQLdb
import anydbm
from libRLP import *
HOST="irc.freenode.net"
PORT=6667
NICK="GeneralFAQ"
IDENT="esperas"
REALNAME="esperas"
OWNER="iwikiwi"
CHANNEL = "#sugar-autohelp"
buffer = ""
clientsock=socket.socket()
clientsock.connect((HOST, PORT))
clientsock.send("NICK %s\r\n" % NICK)
clientsock.send("USER %s %s bla :%s\r\n" % (IDENT, HOST, REALNAME))
clientsock.send("JOIN %s\r\n" % (CHANNEL))
#clientsock.send("PRIVMSG "+CHANNEL+" : *blush*.\r\n")
kitallis='111111111111111111111111111'
kitallis1=''
counter = 0
kitallisconf=''
storage = anydbm.open('ircuserinfo','c')
faqmode = 0
def parsemsg(msg):
cmd={0:'123'}
key={0:'123'}
toprint=''
global counter
global kitallisconf
global kitallis
global kitallis1
global storage
global faqmode
storage = anydbm.open('ircuserinfo','c')
kitallis='111111111111111111111111111113333333333333'
complete=msg[1:].split(':',1) #Parse the message into useful data
print complete
info=complete[0].split(' ')
print info
sender=info[0].split('!')
print sender
msgpart=complete[1]
if sender[0]=='kitallis':
if counter==0:
counter+=1
print sender[1]
kitallisconf=sender[1]
if msgpart.find(' ')!=-1:
cmd=msgpart[0:].split(' ',1)
print cmd[0]
addressed=''
if kitallis1=='':
if (sender[1]==kitallisconf or sender[0]==kitallis) and (cmd[0]=='nekomimi:' or cmd[0]=='nekomimi,'):
clientsock.send('PRIVMSG '+CHANNEL+' :'+ random.choice(['you are scaring me!','dont shout at me!','stop thinking about me you pervert!'])+'\r\n')
clientsock.send('PRIVMSG '+CHANNEL+' :ACTION runs away\r\n')
elif msgpart.find('kitallis')!=-1 or sender[0]==kitallis:
print msgpart[0:]
clientsock.send('PRIVMSG '+CHANNEL+' :Gasp!\r\n')
clientsock.send('PRIVMSG '+CHANNEL+' :ACTION runs away\r\n')
elif sender[1]==kitallisconf:
clientsock.send('PRIVMSG '+CHANNEL+' :You cant fool me!\r\n')
clientsock.send('PRIVMSG '+CHANNEL+' :ACTION runs away\r\n')
if cmd[0] == NICK+":":
if faqmode == 1:
process = InputBreaker(cmd[1])
matchobj = Match(process.qEntitySentences)
answer = matchobj.reportAnswer().split('A. ')[1]
answer = answer.replace("\n", "")
print answer
if len(answer) > 500:
answers = [answer[i:i+400] for i in range(0, len(answer), 400)]
clientsock.send("PRIVMSG "+CHANNEL+' :' +sender[0]+', '+ answer[0:400]+ '\r\n')
del answers[0]
for answer in answers:
clientsock.send("PRIVMSG "+CHANNEL+' :'+ answer+ '\r\n')
time.sleep(1)
else:
clientsock.send("PRIVMSG "+CHANNEL+' :' +sender[0]+', '+answer+ '\r\n')
elif cmd[1] == 'mode faq\r\n':
print 'lol'
faqmode = 1
elif cmd[1].find(' is') < 15 and cmd[1].find(' is') > 1 :
clientsock.send("PRIVMSG "+CHANNEL+' :'+ random.choice(['understood :)','okie!','right'])+ '\r\n')
lol=cmd[1]
key = lol.split(' is')
storage[key[0]]=cmd[1]
elif cmd[1] == 'say hello to all\r\n':
clientsock.send("PRIVMSG "+CHANNEL+' :' + random.choice([' hello everyone!!! '])+ '\r\n')
elif cmd[1].find('say hello to')!=-1:
name=cmd[1].split(' to',1)
clientsock.send("PRIVMSG "+CHANNEL+' :' + random.choice(['hello, '])+ name[1].rstrip()+'!!'+ '\r\n')
elif cmd[1]=='hello\r\n' or cmd[1]=='yo\r\n' or cmd[1]=='hi\r\n' or cmd[1]=='hey\r\n':
print cmd[1]
if sender[0]=='mavu':
clientsock.send("PRIVMSG "+CHANNEL+' :' +sender[0] + random.choice([',hey there :3', ',yo! :3 ', ',hello! :3'])+ '\r\n')
if sender[0]=='iwikiwi':
clientsock.send("PRIVMSG "+CHANNEL+' :' + random.choice(['greetings and salutations, Maker! <3', 'maaker <3 '])+ '\r\n')
else:
clientsock.send("PRIVMSG "+CHANNEL+' :' +sender[0] + random.choice([', hey there, ', ', yo! ', ', hello! '])+ '\r\n')
elif cmd[1]=='shutup\r\n' and sender[1]!=kitallisconf:
clientsock.send("PRIVMSG "+CHANNEL+' :' + random.choice(['okay! <3', 'okay... <3 '])+ '\r\n')
kitallis1='nope'
elif cmd[1]=='speak\r\n' and sender[1]!=kitallisconf:
clientsock.send("PRIVMSG "+CHANNEL+' :' + random.choice(['okay! <3', 'okay... <3 '])+ '\r\n')
kitallis1=''
elif cmd[1]=='botsnack\r\n' and sender[1]!=kitallisconf:
clientsock.send("PRIVMSG "+CHANNEL+' :' + random.choice(['thanks! <3', ':) ','yay~'])+ '\r\n')
elif cmd[1]=='ping|PING':
clientsock.send("PRIVMSG "+CHANNEL+' :' +sender[0] +',pong :)' + '\r\n')
else:
yellow=cmd[1].rstrip()
if yellow not in storage:
clientsock.send("PRIVMSG "+CHANNEL+' :'+ random.choice(['huh?!','what?','my maker tells me to be wary of strange words...'])+'\r\n')
else:
clientsock.send("PRIVMSG "+CHANNEL+' :'+ storage[yellow]+'\r\n')
storage.close()
while 1:
buffer=buffer+clientsock.recv(1024)
temp=string.split(buffer, "\n")
print buffer
line=buffer
buffer=temp.pop()
if line:
print line #server message is output
if line.find('PRIVMSG')!=-1: #Call a parsing function
parsemsg(line)
line=line.rstrip() #remove trailing 'rn'
line=line.split()
if line[0]=='PING': #If server pings then pong
clientsock.send('PONG '+line[1]+'n')
|