|
|
|
@ -8,7 +8,6 @@ import os
|
|
|
|
|
|
|
|
|
|
r = Rake()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def chunks(l, n):
|
|
|
|
|
for i in range(0, len(l), n):
|
|
|
|
|
yield l[i:i+n]
|
|
|
|
@ -30,15 +29,15 @@ class HelloBot(irc.bot.SingleServerIRCBot):
|
|
|
|
|
def on_pubmsg(self, c, e):
|
|
|
|
|
print(e.arguments, e.source)
|
|
|
|
|
msg=e.arguments[0]
|
|
|
|
|
print(e.source.split("!")[0][:1])
|
|
|
|
|
incoming_msg = e.arguments[0]
|
|
|
|
|
print(incoming_msg)
|
|
|
|
|
r.extract_keywords_from_text(msg)
|
|
|
|
|
#r.get_ranked_phrases_with_scores()
|
|
|
|
|
listOfKeys = r.get_ranked_phrases()
|
|
|
|
|
|
|
|
|
|
msg_where = ""
|
|
|
|
|
|
|
|
|
|
if incoming_msg != "I don't know anything about that":
|
|
|
|
|
if e.source.split("!")[0][-3:] != "bot" or e.source.split("!")[0][:1] != "A":
|
|
|
|
|
print("true")
|
|
|
|
|
for keyWord in listOfKeys:
|
|
|
|
|
if keyWord in self.index:
|
|
|
|
|
msg = (index.get(keyWord)[0].get('sentence'))
|
|
|
|
@ -46,15 +45,11 @@ class HelloBot(irc.bot.SingleServerIRCBot):
|
|
|
|
|
else:
|
|
|
|
|
msg = "I don't know anything about that"
|
|
|
|
|
msg_where = ""
|
|
|
|
|
|
|
|
|
|
for chunk in chunks(msg, 400):
|
|
|
|
|
c.privmsg(self.channel, chunk)
|
|
|
|
|
print(chunk)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
c.privmsg(self.channel, msg_where)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
c.privmsg(self.channel, chunk)
|
|
|
|
|
else:
|
|
|
|
|
print("bot")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
@ -80,5 +75,5 @@ if __name__ == "__main__":
|
|
|
|
|
myhost = os.uname()[1]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bot = HelloBot(args.channel, "{0}-{1}-bot".format(myhost, len(index)), args.server, args.port, index)
|
|
|
|
|
bot = HelloBot(args.channel, "A-2{}-bot".format(len(index)), args.server, args.port, index)
|
|
|
|
|
bot.start()
|
|
|
|
|