Skip to content
This repository was archived by the owner on Jan 25, 2019. It is now read-only.

Commit 54194b4

Browse files
committed
Less verbose...
1 parent 9c5d08c commit 54194b4

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

responder.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ def load_responses(self):
4848
storage.close()
4949
return
5050

51-
def respond_to(self,c,e,line):
51+
def respond_to(self,line):
5252
for (keyword,response) in self.responses.items():
5353
if line.lower().find(keyword.lower()) != -1:
5454
print("Found %s" % keyword)
55-
c.privmsg(e.target(), response)
55+
return response
5656

5757

5858
def do_command(self,c,e,a):

testbot.py

+19-11
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,22 @@ def on_pubmsg(self, c, e):
116116
# Did someone mention my name?
117117
if line.lower().find(self.connection.get_nickname().lower()) != -1:
118118
if DEBUG: print("Whoopie, someone said my name!!!")
119-
c.privmsg(e.target(),"Wie kann ich dienen?")
120-
121-
# Shall I do some maths?
122-
if line.lower().startswith("calc "):
123-
self.do_math(c, e, line.split(None,1)[1])
119+
120+
# Shall I do some maths?
121+
if line.split(None,1)[-1].lower().startswith("calc "):
122+
msg = self.do_math(line.split(None,2)[-1])
123+
124+
# Did someone say something interesting to respond to?
125+
else:
126+
msg = self.responder.respond_to(line)
127+
128+
if msg:
129+
c.privmsg(e.target(),msg)
130+
else:
131+
#msg = "Wie kann ich dienen?"
132+
#c.privmsg(e.target(),msg)
133+
pass
124134

125-
# Did someone say something interesting to respond to?
126-
self.responder.respond_to(c, e, line)
127135
return
128136

129137
def on_privmsg(self, c, e):
@@ -160,13 +168,13 @@ def on_privmsg(self, c, e):
160168

161169
return
162170

163-
def do_math(self,c,e,expr):
171+
def do_math(self,expr):
164172
"""
165173
Just generate a link to Wolfram Alpha containing the given expression
166174
"""
167175
url = "http://www.wolframalpha.com/input/?i=%s" % quote(expr)
168-
c.privmsg(e.target(),"I'm not that good at maths... Try it here: %s" % url)
169-
return
176+
177+
return "I'm not that good at maths... Try it here: %s" % url
170178

171179
def help(self,c,e):
172180
"""
@@ -202,7 +210,7 @@ def on_join(self,c,e):
202210
if DEBUG: print nick + " joined"
203211

204212
if nick != c.get_nickname():
205-
c.privmsg(channel,"Hello %s" % nick)
213+
#c.privmsg(channel,"Hello %s" % nick)
206214
level = dbstuff.getLevel(channel,host)
207215
if DEBUG: print("level: %s on %s in %s has %s" % (nick, host, channel, level))
208216
if (level == "v") or (level == "o"):

0 commit comments

Comments
 (0)