Git Product home page Git Product logo

simplepybot's Introduction

Simplepybot is an attempt at a dead simple python irc bot that got way out of control

It is currently targeting python3

#Configuration configuration is done by editing the basic.ini file, you can define more core and custom modules by adding them.

to allow a module to load the following settings Must be defined

class=Name of python class
filename = filename class lives in
modulename = what name the module should have

If you want to include the module as an accessible attribute on the bot object (much like the ircengine,identengine and authengine modules) then add

core = attributename

A module should pull all and any configuration from the config file, module creators are advised to do

self.config = bot.config[self.module_name]

aside from the predefined, class,filename,modulename attributes just about anything can be put in there, see the python configparser docs for more info

#Writing your own module create a new class with an init that accepts the following

__init__(self, bot, module_name)

to do logging in your module setup a log like so

self.log = logging.getLogger(bot.log_name+'.'+module_name)

the end user will configure the log with the logging.json file, you may wish to provide a default/example config

you can get access to an sqlite db connection from bot.db, make sure you prefix the tables with your module_name, this makes it easier for an end user to reuse your module with others

finally, specify a set of command/event handlers on the commands attrib of your class

self.commands = [
    bot.command(r'regex expression', self.func),
    ...
]
self.events[
    bot.event(botflag, self.func),
    ...
]

see event_util for documentation on the event/command handlers, commands are for responding to user input and events are for hooking into real irc events (TODO write a nice version)

for the event botflags you can use any option from the numerics.py file, get them by adding the following import to your module

import numerics as nu

you can then reference it with

nu.PRIV_MSG
...

See modules/aliasmodule.py for a super simple example of a module

simplepybot's People

Contributors

bdl-vic avatar catalystfd avatar chrisosaurus avatar domnomnom avatar optimumtact avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

domnomnom

simplepybot's Issues

Define custom roles as config

Building on #11 and #12
allow end users to override and define custom roles in a config file, granting as many or as few grants as they would like.

Also allows overriding the default role archetypes to tweak what permissions are available.

Roles with preassigned "grants"

Building on the work in #11

If would be excellent if the authentication system understood the concept of a "role" that is a series of grants, any user who has "role" inherits automatically all the grants tied to that role.

The system should ship with some basic role archetypes, root, operator, halfop/mod, user, ignored - these will always be present and module authors can automatically add their grants to these archetypes (make the simple cases default and easy)

no way to identify a priv msg was a command

it would be good if events handlers could modify the base event to set it as a BOT_COMMAND, or some other prefix if it triggered one or more of the bot commands

This would require the event is properly returned at every level of the event stack so that the updated copy is always used

Queue messages until "condition" is met

Consider that you often cannot send irc join messages until you have gone through at least the basic connection to the irc serv.

the bot currently has some hardcoded logic to queue any and all join events until it sees the end of the message of the day, or the no motd response and then it sends all queued channel join events.

This would be quite useful if this abstraction could be extended to support generic queueing for outgoing bot events.

The current plan looks a little something like this

a dict of {stateflag -> list} where the list is a list of held outbound events

when the stateflag is set to true, the queued list of events is sent and all future events pertaining to this stateflag are sent immediately.

If the stateflag is toggled back to false then they start queueing again.

I have not yet encountered any other items that would potentially need this yet, but I can think of a few uses where a module might find it useful, hence the generalisation

nickhost command is sending blank text out

bot.network INFO << orangesnz!oranges@user/orangesnz PRIVMSG ['#channel'] !nickhost orangesbotnz
bot.network INFO >> PRIVMSG #channel :
bot.network INFO << server 412 ['orangesbotnz'] No text to send

authentication as keys, not numbers (grants)

Right now authentication is handled as a number, if your users assigned number is < number required to do task then you are "allowed"

I would like to change this to be keys instead,
i.e modulename/granttype

and if your user has that modulename/granttype then you are allowed to complete that action

command help handling

There needs to be a way for the bot to send the user help on commands

module authors need to be able define how help requests are handled for their module

Improve reconnection logic

The bot does reconnect automatically but it will not rejoin any channels, so it simply connects to the server and sits there after a timeout.

It should track the channels it is "in" and rejoin them when a reconnection event occurs

Note that the identengine already tracks this to some extent with the channel->users map.

However my intention was to write a new core engine "channelmanager" that tracks channels the bot should be in and ensures that if it gets kicked/leaves/quits/dies that it auto rejoins them on next reconnect.

Ideally this would partially depend on #10 being implemented first

no spam control

bot needs some kind of spam control

track message counts going out and slow + queue as needed

track inbound command messages, if one host sends too many ignore host for increasing amounts of time

Split engine and modules to clarify distinction

Modules are just things that respond to user input and events

engines provide new functionality for other modules to build off (i.e ident engine, auth engine and so forth)

Splitting them will clarify the role of each and how they fit together, i.e the identengine should be able to be replaced under the hood and the identcontrol module should continue to work as normal.

Error in the identengine handler for nicks

bot ERROR Error in module event handler: identengine
Traceback (most recent call last):
File "commandbot.py", line 242, in handle_event
if event(m_event):
File "/home/oranges/simplepybot/event_util.py", line 38, in process
func(*message.data)
File "/home/oranges/simplepybot/modules/identengine.py", line 176, in user_quit
self.delete_user(nickhost)
File "/home/oranges/simplepybot/modules/identengine.py", line 56, in delete_user
del self.nickmap[nick]
NameError: name 'nick' is not defined

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.