Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New bot features; Comments cleanup; Add command-line arg #10

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ http://twistedmatrix.com/documents/current/words/examples/ircLogBot.py

To Run:

$ python ekan0ra.py <channel_name>
$ python ekan0ra.py

Options:
startclass in the bot's pm.
endclass in bot's pm.
pingall - pingall: [message]
give ops to some user - right: <username>
take ops from user - unright: <username>
Give voice to some body- voice: <username>
Removes voice of some body- unvoice: <username>
4 changes: 4 additions & 0 deletions config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[SectionOne]
Host: irc.freenode.net
Port: 6667
Channel: sheesh
44 changes: 41 additions & 3 deletions ekan0ra.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,25 @@
import time, sys, os
import datetime
import random
import ConfigParser

now = datetime.datetime.now()
Config = ConfigParser.ConfigParser()
Config.read("config.ini")

def ConfigSectionMap(section):
values = {}
options = Config.options(section)
for option in options:
try:
values[option] = Config.get(section, option)
if values[option] == -1:
DebugPrint("skip: %s" % option)
except:
print("exception on %s!" % option)
values[option] = None
return values


class MessageLogger:
"""
Expand Down Expand Up @@ -71,7 +88,7 @@ def upload_logs(self, channel):
os.system(cmd)
#msg = 'The logs are updated to: http://sayanchowdhury.dgplug.org/irclogs/%s'%self.filename
#self.say(channel, msg)
# callbacks for events
# callbacks for events

def signedOn(self):
"""Called when bot has succesfully signed on to server."""
Expand Down Expand Up @@ -104,6 +121,27 @@ def privmsg(self, user, channel, msg):
self.pingmsg = msg.lower().lstrip('pingall:')
self.names(channel).addCallback(self.pingall)

# Give right to anybody
if msg.lower().startswith('right:') and user_cond:
msgs = msg.lower().lstrip('right: ')
self.mode(channel,True,"+o",limit=None,user=msgs, mask=None)

# Take right from anybody
if msg.lower().startswith('unright:') and user_cond:
msgs = msg.lower().lstrip('unright: ')
self.mode(channel,True,"-o",limit=None,user=msgs, mask=None)

#Give voice to anybody
if msg.lower().startswith('voice:') and user_cond:
msgs = msg.lower().lstrip('voice:')
self.mode(channel,True,"+v",limit=None,user=msgs, mask=None)

#Take voice of anybody
if msg.lower().startswith('unvoice:') and user_cond:
msgs = msg.lower().lstrip('unvoice:')
self.mode(channel,True,"-v",limit=None,user=msgs, mask=None)


def action(self, user, channel, msg):
"""This will get called when the bot sees someone do an action."""
user = user.split('!', 1)[0]
Expand Down Expand Up @@ -189,10 +227,10 @@ def clientConnectionFailed(self, connector, reason):
log.startLogging(sys.stdout)

# create factory protocol and application
f = LogBotFactory(sys.argv[1])
f = LogBotFactory(ConfigSectionMap("SectionOne")['channel'])

# connect factory to this host and port
reactor.connectTCP("irc.freenode.net", 6667, f)
reactor.connectTCP(ConfigSectionMap("SectionOne")['host'], int(ConfigSectionMap("SectionOne")['port']), f)

# run bot
reactor.run()