Python IRC bot project reddit / irc ---------------------------------------------------------------------- 546875674c6966650d0a · 2018-01-26 20:32 Is there anyone in here who has experience with python based IRC bot programming? I'm just getting deeper into python (more than just local 2 line scripts) and decided to try and make a very basic bot project. Just wondering if there's anyone else who's got experience doing this that might want to lend some advice, or even someone else who's interested in working on such a thing? Anyone? Anyone? Bueller? Edit: [Github repo](https://github.com/rhanthony/GoatBot) which I'm also making myself get better at using Edit2: Got it working on some IRC networks, not others, because who needs server standards right? Thanks for all the advice. I'll be annoying some of you directly in the future! :) ---------------------------------------------------------------------- thebmo · 2018-01-26 21:07 HI, I have thought of doing the same, but opted a while back to use pre- existing library. I use Phenny, an older framework designed with python 2.7.x (https://github.com/sbp/phenny), last i heard it was abandoned and there is a python 3.x implementation that has an active dev (not sure where the repo lives atm). If you are more interested in learning how build your own and dont know where to start, learn about socket programming in python (https://docs.python.org/2/howto/sockets.html) and try pulling the git repo and poking around. Hope this helps. ---------------------------------------------------------------------- Jonno_FTW · 2018-01-27 02:29 My first attempt at a bot used raw sockets. After that I moved to the twisted framework which makes everything much easier. ---------------------------------------------------------------------- williamjacksn · 2018-01-27 17:18 For my first attempt to write an IRC bot in Python, I used [the `irc` package](https://github.com/jaraco/irc). After I had a better idea about how IRC works, I wrote my own replacement for `irc` using [`asyncio.Protocol`](https://docs.python.org/3/library/asyncio- protocol.html#protocols) in the standard library. I named my implementation [humphrey](https://github.com/williamjacksn/humphrey). I'd be happy to lend a hand or answer any questions. Message me if you want to. ---------------------------------------------------------------------- kihashi · 2018-01-27 18:54 Phenny was forked to Willie, which is now called Sopel. There's also a fork called Jenni, iirc. https://sopel.chat ---------------------------------------------------------------------- 546875674c6966650d0a · 2018-01-27 19:06 Thanks! I'll shoot you a pm. I'm trying to write this just using the raw sockets right now so I get a bit of exposure to that along the way, but I may trade up for a framework after I get the 'foundation' in my head. ---------------------------------------------------------------------- 546875674c6966650d0a · 2018-01-27 21:58 I have heard a lot of mention of Twisted, but I want to just get a basic understanding under my feet before I jump into a framework. I like to know how the sausage is made to some degree before just buying it in a package. ---------------------------------------------------------------------- 546875674c6966650d0a · 2018-01-27 22:00 I am working on just using a socket stream right now. That's what I did with the PHP version I had up in an hour or so, and I thought the python version wouldn't be a big deal :/ hasn't connected yet. I want to learn how to interact with it on a base level, then I'll swap out and use a framework of some type to expand and add better features and such. First I want to know the parts of the car before I just hope in and floor it. ---------------------------------------------------------------------- Jonno_FTW · 2018-01-27 22:21 That's all fine. You'll probably need to read the spec first so you know the message format and what all the different commands mean. ---------------------------------------------------------------------- 546875674c6966650d0a · 2018-01-27 23:02 Well I was on IRC for like a decade before, and even was an op for a short time so I know what all the commands I'll need do... right now I'm stuck at a point of getting the Python to properly read/write through the socket I think. I haven't even gotten to the point of sending very many commands. ---------------------------------------------------------------------- Jonno_FTW · 2018-01-28 00:57 Being on IRC won't make you familiar with the messages that come off the socket and how to split them up. But you'll probably figure that out soon enough. Plus there's other commands you don't normally see that your IRC client handles for you that you need to manage. ---------------------------------------------------------------------- 546875674c6966650d0a · 2018-01-28 02:32 Yeah. I have awareness I guess you could say of CTCP and Pings and such... It'll be fun working with them. But... I apparently can't even make an initial connection in python, while my PHP not is working fine :/ ---------------------------------------------------------------------- Jonno_FTW · 2018-01-28 02:51 My shitty python code is here if you're interested: https://github.com/JonnoFTW/TwatBot/blob/master/twatbot.py ---------------------------------------------------------------------- 546875674c6966650d0a · 2018-01-28 03:27 Wow. I am out of my depth. Thanks. This will give me a bunch to break down and digest! ---------------------------------------------------------------------- Jonno_FTW · 2018-01-28 04:02 Keep in mind that it's very poorly written. ---------------------------------------------------------------------- 546875674c6966650d0a · 2018-01-28 07:16 It works... so not as poorly as mine.