Jump to content

My Python IRC Bot PikeBot


NotPike

Recommended Posts

Hi,

I've been crunching away at this python3 script(s) for the past month and I would like some input on how to make it better. I based this bot off of Paul Mutton's work from the book “IRC Hacks.” Threading, having less hard coded variables, self healing,  and making this code less dyslexic is definitely on the to do list! Let me know what you think :3

https://github.com/notpike/PikeBot

Link to comment
Share on other sites

On 9/26/2016 at 0:08 AM, cooper said:

I'm puzzled why you have 2 separate but almost equal IRC classes.

That's me cheating. I was having trouble creating two different bots on the same server using the same class so I cheated and made the another class to accomplish my goal. Something that needs to be fixed with threading :3.

Link to comment
Share on other sites

Sorry if this seems too critical or is too much, but a few quick points:

  • Personally, I wouldn't use "from module import *" if I'm just using a single class, once. If anything, you can "from irc import IRC", which would work in just the same way. In fact, what I would do is "import irc" then use "irc.IRC()". Having those namespaces can be useful when you are using more modules.
  • I noticed a lot of try: except:. You probably can do this in a better way. I haven't looked too closely, but it looks like your error is an index error for a list/tuple. I'm not sure what your algorithm is, but you almost certainly can do it in a way that is more elegant.
  • You should delete irc2.py. I think you're not even using it at all.
  • I'm confused on why this line even exists when you have this one when the class is instantiated.
  • IIRC Django has a settings.py from which variables are collected. I personally use a dictionary which I import for my settings. That way your settings are separated from your initialisation script.
  • This line will always return, no matter what. I don't think the "while 1:" changes anything at all.
  • The way I design a module is have all of the global variables at the very top (basically everything up to the art), then functions, then code underneath a "if __name__ == '__main__':". That is even if I'm not using the muliprocess module.

Don't be ever ashamed to post work, you needn't call it dyslexic. I think it's generally good, with just a few rough edges. How long have you been using Python?

 

Link to comment
Share on other sites

13 hours ago, Garda said:

Sorry if this seems too critical or is too much, but a few quick points:

  • Personally, I wouldn't use "from module import *" if I'm just using a single class, once. If anything, you can "from irc import IRC", which would work in just the same way. In fact, what I would do is "import irc" then use "irc.IRC()". Having those namespaces can be useful when you are using more modules.
  • I noticed a lot of try: except:. You probably can do this in a better way. I haven't looked too closely, but it looks like your error is an index error for a list/tuple. I'm not sure what your algorithm is, but you almost certainly can do it in a way that is more elegant.
  • You should delete irc2.py. I think you're not even using it at all.
  • I'm confused on why this line even exists when you have this one when the class is instantiated.
  • IIRC Django has a settings.py from which variables are collected. I personally use a dictionary which I import for my settings. That way your settings are separated from your initialisation script.
  • This line will always return, no matter what. I don't think the "while 1:" changes anything at all.
  • The way I design a module is have all of the global variables at the very top (basically everything up to the art), then functions, then code underneath a "if __name__ == '__main__':". That is even if I'm not using the muliprocess module.

Don't be ever ashamed to post work, you needn't call it dyslexic. I think it's generally good, with just a few rough edges. How long have you been using Python?

 

Hay, thanks for the input! I'll review the corrections when I have time and see if I can brake it again when I implement threading.

Nah I'm not ashamed of my work, I poke fun at myself because people think I'm too serious lol. I'm just happy being able to figure this out this much.  I started learning Python last winter but I started this project about a month ago. Besides that I've only been making small scripts to use with RFcat.  Figured I would challenge myself and learn something new with sockets.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...