Author Topic: IRC Score Bot  (Read 8230 times)

0 Members and 2 Guests are viewing this topic.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: IRC Score Bot
« Reply #15 on: May 09, 2011, 09:33:43 pm »
Yeah true. Also, I think two rating systems would get confusing, and I would prefer that rating remains only on posts.

Offline merthsoft

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 241
  • Rating: +63/-1
    • View Profile
Re: IRC Score Bot
« Reply #16 on: May 10, 2011, 09:29:49 am »
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.
It definitely can get spammy. There're also a lot of junk entries that I go through and clean up. An addition that helps to abate everyone wanting to check all the scores is that you can access the scores online, so if people get overly spammy you can point them there. I think if you include that, you can lessen the abuse. That being said, we do have to be pretty vigilant when it comes to moderating DecBot abuse.
Shaun

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: IRC Score Bot
« Reply #17 on: May 10, 2011, 04:00:10 pm »
Thanks everyone for your opinions. I changed my opinion and will not even ask to upload this at #omnimaga.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: IRC Score Bot
« Reply #18 on: May 10, 2011, 04:50:42 pm »
Ah ok. Yeah I think the issue is that it could get out of control, and since moderators are often busy, it would be hard to stop :<

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: IRC Score Bot
« Reply #19 on: May 10, 2011, 05:28:28 pm »
As much as I like Decbot on #cemetech, it'd definitely get abused in #omnimaga. For example, "Lobster" would probably get >9000 ratings in the first 42 hours. And the memes that I'm obviously inserting in here would get inflated respect too. Let's just keep it on the forums.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: IRC Score Bot
« Reply #20 on: May 10, 2011, 09:52:05 pm »
Indeed, and I am sure some people would try to make sure someone's rating remains exactly at 666. Omnimaga in general mostly got younger users since it attracts a lot more newer coders than other ones, so inevitably there are some strange things that are going to happen. :P (no offense intended of course)

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: IRC Score Bot
« Reply #21 on: May 12, 2011, 01:47:10 pm »
Even if this is never going to be in #omnimaga, I worked a bit on it:

Code: [Select]
#!/usr/bin/env python

import datetime
import hashlib
import os
import random
import sys
import time
import urllib

from twisted.words.protocols import irc
from twisted.internet import protocol
from twisted.internet import reactor

class 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()

Actually, I just made even more updates:

Code: [Select]
#!/usr/bin/env python

import datetime
import hashlib
import os
import random
import sys
import time
import urllib

from twisted.words.protocols import irc
from twisted.internet import protocol
from twisted.internet import reactor

class 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()
« Last Edit: May 12, 2011, 01:55:05 pm by Scout »