0 Members and 1 Guest are viewing this topic.
Yeah but #cemetech had less spam than us without the bot, so adding it there wasn't too bad. In #omnimaga there's more randomness so imagine how bad it will be if people go random and starts abusing the bot too. And then it gets much harder for admins to stop the sapam if there is too much.
#!/usr/bin/env pythonimport datetimeimport hashlibimport osimport randomimport sysimport timeimport urllibfrom twisted.words.protocols import ircfrom twisted.internet import protocolfrom twisted.internet import reactorclass MyBot(irc.IRCClient): def _get_nickname(self): return self.factory.nickname nickname = property(_get_nickname) def signedOn(self): self.join(self.factory.channel) def joined(self, channel): print "*** Joined %s" % channel self.myDict = {} def privmsg(self, user, channel, msg): user = user.split('!')[0] if msg[len(msg)-2:] == "++": if msg.split('++')[0] == user: self.msg(channel,"You can't plus yourself") return try: self.myDict[msg.split('++')[0]] += 1 print "+1 for %s by %s" % (msg.split('++')[0],user) return except KeyError: self.myDict[msg.split('++')[0]] = 1 print "The first +1 for %s by %s" % (msg.split('++')[0],user) return if msg[len(msg)-2:] == "--": try: self.myDict[msg.split('--')[0]] = self.myDict[msg.split('--')[0]] - 1 print "-1 for %s by %s" % (msg.split('++')[0],user) return except: self.myDict[msg.split('--')[0]] = -1 print "The first -1 for %s by %s" % (msg.split('++')[0],user) return if msg.split()[0] == '!score': try: msgToDisplay = msg.split()[1] + ": " + str(self.myDict[msg.split()[1]]) self.msg(channel,msgToDisplay) print "I answered to %s: %s" % (user,msgToDisplay) return except KeyError: self.msg(channel,"Non-existing member: %s" % msg.split()[1]) print "Non-existing member: %s" % msg.split()[1]class MyBotFactory(protocol.ClientFactory): protocol = MyBot def __init__(self, channel, nickname='scoreBot'): self.channel = channel self.nickname = nickname def clientConnectionLost(self, connector, reason): print "Lost connection (%s), reconnecting." % (reason,) connector.connect() def clientConnectionFailed(self, connector, reason): print "Could not connect: %s" % (reason,)def main(): network = 'irc.freenode.net' reactor.connectTCP(network, 6667, MyBotFactory('#python-forum')) reactor.run()if __name__ == "__main__": main()
#!/usr/bin/env pythonimport datetimeimport hashlibimport osimport randomimport sysimport timeimport urllibfrom twisted.words.protocols import ircfrom twisted.internet import protocolfrom twisted.internet import reactorclass MyBot(irc.IRCClient): def _get_nickname(self): return self.factory.nickname nickname = property(_get_nickname) def signedOn(self): self.join(self.factory.channel) def joined(self, channel): print "*** Joined %s" % channel self.myDict = {} def privmsg(self, user, channel, msg): user = user.split('!')[0] if msg[len(msg)-2:] == "++": if msg.split('++')[0] == user: self.msg(channel,"You can't plus yourself") return try: self.myDict[msg.split('++')[0]] += 1 print "+1 for %s by %s" % (msg.split('++')[0],user) return except KeyError: self.myDict[msg.split('++')[0]] = 1 print "The first +1 for %s by %s" % (msg.split('++')[0],user) return elif msg[len(msg)-2:] == "--": try: self.myDict[msg.split('--')[0]] = self.myDict[msg.split('--')[0]] - 1 print "-1 for %s by %s" % (msg.split('++')[0],user) return except: self.myDict[msg.split('--')[0]] = -1 print "The first -1 for %s by %s" % (msg.split('++')[0],user) return elif msg.split()[0] == '!score': try: msgToDisplay=msg.split()[1]+": %s" % str(self.myDict[msg.split()[1]]) self.msg(channel,msgToDisplay) print "I answered to %s: %s" % (user,msgToDisplay) return except KeyError: msgToDisplay="Non-existing member: %s" % msg.split()[1] self.msg(channel,msgToDisplay) print "I answered to %s: Non-existing member: %s" % (user,msg.split()[1])class MyBotFactory(protocol.ClientFactory): protocol = MyBot def __init__(self, channel, nickname='scoreBot'): self.channel = channel self.nickname = nickname def clientConnectionLost(self, connector, reason): print "Lost connection (%s), reconnecting." % (reason,) connector.connect() def clientConnectionFailed(self, connector, reason): print "Could not connect: %s" % (reason,)def main(): network = 'irc.freenode.net' reactor.connectTCP(network, 6667, MyBotFactory('#python-forum')) reactor.run()if __name__ == "__main__": main()