1
1
Fork
You've already forked MegBot
0

Alias plugins calls and regex? #19

Closed
opened 2013年01月18日 10:25:57 +01:00 by tsyesika · 2 comments

I'd be cool if I've written a plugin I could get it called on not just the name of the plugin but also setup aliases e.g.

the help.py plugin also aliased to 'commands' so commands would also call it? I think that would be a good idea.

We also could have so maybe we want a silly plugin for animal noises so we could have

bot
and it'll respond with

if it doesn't know it maybe it could ask for it and store it so it does know so

!cowbot
moo

!pigbot
oink

etc... This could be handled by one plugin and allow some regex of some description or a list of things? I'm not sure but some way of calling a plugin other than by it's name could be really handy.

I'd be cool if I've written a plugin I could get it called on not just the name of the plugin but also setup aliases e.g. the help.py plugin also aliased to 'commands' so <trigger>commands would also call it? I think that would be a good idea. We also could have so maybe we want a silly plugin for animal noises so we could have <trigger><animal>bot and it'll respond with <animal noise> if it doesn't know it maybe it could ask for it and store it so it does know so !cowbot moo !pigbot oink etc... This could be handled by one plugin and allow some regex of some description or a list of things? I'm not sure but some way of calling a plugin other than by it's name could be really handy.
moggers87 commented 2013年03月09日 02:31:25 +01:00 (Migrated from github.com)
Copy link

This can sort of be done with the new event system, but it needs more work to make it usable. Jess and I were talking about how to deal with this issue and came up with something like this:

import random
def init(connection):
 Event.register("pigbot", chooser)
 Event.register("8ball", chooser)
 Event.register("trevor", magical)
def chooser(connection):
 if not Info.args:
 Channel.action("slaps %s" % Info.nick)
 else:
 #config contains multiple entries for different aliases
 choices = Config["replies"][Info.plugin_name]
 Channel.send(random.choice(choices))
def magical(connection):
 Channel.action('waves his magic wand!')
 chooser(connection)
 Channel.action('takes a bow')

The idea is to make aliasing the norm and get rid of "call by filename"

This can sort of be done with the new event system, but it needs more work to make it usable. Jess and I were talking about how to deal with this issue and came up with something like this: ``` import random def init(connection): Event.register("pigbot", chooser) Event.register("8ball", chooser) Event.register("trevor", magical) def chooser(connection): if not Info.args: Channel.action("slaps %s" % Info.nick) else: #config contains multiple entries for different aliases choices = Config["replies"][Info.plugin_name] Channel.send(random.choice(choices)) def magical(connection): Channel.action('waves his magic wand!') chooser(connection) Channel.action('takes a bow') ``` The idea is to make aliasing the norm and get rid of "call by filename"
Author
Owner
Copy link

Okay this will be done pretty much by #37

However, regex won't be yet, that should come later but definitly should come. Maybe 0.07?

Okay this will be done pretty much by #37 However, regex won't be yet, that should come later but definitly should come. Maybe 0.07?
Sign in to join this conversation.
No Branch/Tag specified
master
tests-question-mark
too-tired-to-test
JT-keeper
master-backports
No results found.
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
tsyesika/MegBot#19
Reference in a new issue
tsyesika/MegBot
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?