ayust / kitnirc Goto Github PK
View Code? Open in Web Editor NEWPython IRC bot framework.
License: MIT License
Python IRC bot framework.
License: MIT License
I don't know how much you would like to to have built in but a standard authentication module might be a good idea.
The one I wrote is a bit premature. I had a section in the config file for each host which contained nicks and passwords.
[irc.freenode.net]
nick = foo
nick_password = bar
[irc.geekshed.net]
nick = oof
nick_pasword = rab
The module could look something like this
class NickToolsModule(Module):
"""A KitnIRC module which automatically configures nick. """
@Module.handle("WELCOME")
def register_nick(self, client, hostmask):
_log.info("Beginning automatic nick configuration...")
host = client.server.host
if self.controller.config.has_option(str(host), "nick"):
nick = self.controller.config.get(str(host), "nick")
client.nick(nick)
if self.controller.config.has_option(str(host), "nick_password"):
nick_password = self.controller.config.get(str(host), "nick_password")
client.msg("NickServ", "IDENTIFY {}".format(nick_password))
_log.info("Automatic nick configuration complete.")
It would be nice to be able to change the log level without restarting the skeleton bot; that's about the only reason I ever do.
For people that would like to develop general purpose modules where should they go? Should they be submitted in https://github.com/ayust/kitnirc/tree/master/kitnirc/contrib or distributed in PyPi?
If PyPi is there any good naming or packaging convention that should be followed?
I am thinking a twitter module in contrib would be called contrib/twitter.py
and in PyPi I would probably call it kitntwitter
I am trying to op someone based on a command, but kitnirc seems determined that I am not in the channel.
_log.info("Channel: %r", recipient)
_log.info("Server.channels: %r", client.server.channels)
client.mode(recipient, add={'o': [actor]})
client.reply(recipient, actor, "Okay.")
Log output
INFO 2014-07-14 13:44:12,824 modules.helloworld:0034 - Channel: kitnirc.client.Channel('#yamc')
INFO 2014-07-14 13:44:12,824 modules.helloworld:0035 - Server.channels: {'#yamc': kitnirc.client.Channel('#yamc')}
WARNING 2014-07-14 13:44:12,825 kitnirc.client:0442 - Ignoring request to set modes in channel '#yamc' because we are not in that channel.
Relevant code:
https://github.com/ayust/kitnirc/blob/master/kitnirc/client.py#L429
It would be nice if, when a module load fails, kitnbot replied with the reason attached to the ImportError. (I can write this myself, just posting an issue since I'm not going to get around to it right now.)
I am having trouble connecting to znc. It seams the problem is znc does not like the \r\n in the password but this does not make sense. The following works but not in https://github.com/pdxacm/acmbot. BTW I changed the password. I don't know if this i a bug or not
derp()
{
echo -en "PASS password\r\n"
echo "NICK AcmBot"
echo "USER AcmBot AcmBot 127.0.0.1 :AcmBot"
echo "PRIVMSG #acm :Hello from a script"
echo "QUIT"
}
derp "$@" | openssl s_client -quiet -connect rita.cat.pdx.edu:1919 &> /dev/null
$ znc --version
ZNC 0.206+deb1 - http://znc.in
This would be nice
Traceback (most recent call last):
File "main.py", line 113, in <module>
main()
File "main.py", line 107, in main
client.run()
File "/home/kristoffer/.virtualenvs/yamcbot/src/kitnirc/kitnirc/client.py", line 299, in run
self._buffer += self.socket.recv(4096)
socket.error: [Errno 104] Connection reset by peer
I am having a weird issue where the bot just never joins the channel (autojoin contrib module never seems to do anything), and then after a while the bot is disconnected
~/code/yamcbot] (master●●) python main.py --loglevel INFO
INFO 2014-10-23 10:49:37,929 kitnirc.modular:0263 - Loaded the following modules: ['kitnirc.contrib.healthcheck', 'kitnirc.contrib.admintools', 'kitnirc.contrib.autojoin', 'kitnirc.contrib.commands', 'kitnirc.contrib.cron', 'modules.eve', 'modules.channel_control', 'modules.ruter']
INFO 2014-10-23 10:49:37,930 kitnirc.client:0197 - Adding event handler for new event REMOVECOMMAND.
INFO 2014-10-23 10:49:37,931 kitnirc.client:0197 - Adding event handler for new event ADDCOMMAND.
INFO 2014-10-23 10:49:37,931 kitnirc.client:0197 - Adding event handler for new event STARTUP.
INFO 2014-10-23 10:49:37,931 kitnirc.client:0197 - Adding event handler for new event NICK.
INFO 2014-10-23 10:49:37,931 kitnirc.client:0197 - Adding event handler for new event LIST_COMMANDS.
INFO 2014-10-23 10:49:37,931 kitnirc.client:0197 - Adding event handler for new event ADDCRON.
INFO 2014-10-23 10:49:37,932 kitnirc.client:0197 - Adding event handler for new event REMOVECRON.
INFO 2014-10-23 10:49:37,932 kitnirc.contrib.healthcheck:0061 - Healthcheck running: delay=60 timeout=90
INFO 2014-10-23 10:49:37,932 kitnirc.client:0197 - Adding event handler for new event CORPORATION.
INFO 2014-10-23 10:49:37,933 kitnirc.client:0197 - Adding event handler for new event COMMANDS.
INFO 2014-10-23 10:49:37,933 kitnirc.client:0197 - Adding event handler for new event SOLARSYSTEM.
INFO 2014-10-23 10:49:37,933 kitnirc.client:0197 - Adding event handler for new event TYPEINFO.
INFO 2014-10-23 10:49:37,933 kitnirc.client:0197 - Adding event handler for new event MARKETQUOTE.
INFO 2014-10-23 10:49:37,933 kitnirc.client:0197 - Adding event handler for new event RUTER.
INFO 2014-10-23 10:49:37,934 modules.eve:0034 - Registering commands...
INFO 2014-10-23 10:49:37,934 kitnirc.contrib.commands:0126 - Adding command 'jita' => 'MARKETQUOTE'.
INFO 2014-10-23 10:49:37,934 kitnirc.contrib.commands:0126 - Adding command 'typeid' => 'TYPEINFO'.
INFO 2014-10-23 10:49:37,934 kitnirc.contrib.commands:0126 - Adding command 'system' => 'SOLARSYSTEM'.
INFO 2014-10-23 10:49:37,934 kitnirc.contrib.commands:0126 - Adding command 'corporation' => 'CORPORATION'.
INFO 2014-10-23 10:49:37,934 kitnirc.contrib.commands:0126 - Adding command 'corp' => 'CORPORATION'.
INFO 2014-10-23 10:49:37,935 modules.ruter:0030 - Registering commands...
INFO 2014-10-23 10:49:37,935 kitnirc.contrib.commands:0126 - Adding command 'ruter' => 'RUTER'.
INFO 2014-10-23 10:49:37,935 kitnirc.contrib.commands:0126 - Adding command 'commands' => 'LIST_COMMANDS'.
INFO 2014-10-23 10:49:37,935 kitnirc.client:0250 - Connecting to irc.freenode.org as belt ...
INFO 2014-10-23 10:49:38,198 kitnirc.client:0263 - Connected to irc.freenode.org.
INFO 2014-10-23 10:49:38,199 kitnirc.client:0323 - Requesting nick change to 'belt'
INFO 2014-10-23 10:49:38,200 kitnirc.client:0335 - Requesting user info update: username=belt realname=belt
Exception in thread healthcheck:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 505, in run
self.__target(*self.__args, **self.__kwargs)
File "/home/kristoffer/code/yamcbot/venv/local/lib/python2.7/site-packages/kitnirc/contrib/healthcheck.py", line 72, in loop
self.controller.client.send("PING")
File "/home/kristoffer/code/yamcbot/venv/local/lib/python2.7/site-packages/kitnirc/client.py", line 319, in send
self.socket.send(msg + "\r\n")
error: [Errno 32] Broken pipe
This suddenly happens, when kicking someone, but things have been only semi-working recently. I am not sure what happened on the server but the channel name suddenly seems to be all capitalised, while in my configs it is not capitalised, and that is causing stuff to break. Error below:
ERROR 2014-08-12 13:08:29,918 kitnirc.client:0222 - Error while processing event 'LINE': KeyError('#yamc',)
Traceback (most recent call last):
File "/home/kristoffer/.virtualenvs/yamcbot/src/kitnirc/kitnirc/client.py", line 217, in dispatch_event
if handler(self, *args):
File "/home/kristoffer/.virtualenvs/yamcbot/src/kitnirc/kitnirc/client.py", line 590, in on_line
parser(client, command, actor, args)
File "/home/kristoffer/.virtualenvs/yamcbot/src/kitnirc/kitnirc/client.py", line 708, in _parse_kick
channel = client.server.channels[channel]
KeyError: '#yamc'
We can tell the server what nick we want, but unless I'm missing something we can't tell whether we've gotten it.
I found myself wanting to be able to send colored/styled messages, and I came across this that already has all the codes defined.
https://github.com/greerrrr/nicedice/blob/master/nicedice/ircformat.py
Currently I have just put that file in my modules dir, so I can do things like
self.controller.client.msg(recipient, ircformat.style("Hello world", "bold"))
Perhaps we can grab that and put it into kitnirc core? It's common to want to be able to do things like that.
This would also be nice
It would be nice if it had a built in way of displaying available commands to the channel.
It seems like that was the intention from the beginning (with the help texts).
Possibly it would be nice to change the command handling so that you specify the valid parameters and such, and the help text can be automatically generated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.