| 1 |
import irclib |
| 2 |
import time |
| 3 |
|
| 4 |
### These settings will be added to the bot settings prefixed with the module name, ### |
| 5 |
### for example the following will add the setting 'test_example' and it will be set ### |
| 6 |
### to "Default value" if it doesn't exist in the settings since before. ### |
| 7 |
test_settings = { 'example': "Default value" } |
| 8 |
|
| 9 |
### A list with module names which this module requires. ### |
| 10 |
test_requires = [] |
| 11 |
|
| 12 |
### A list with functions in this module to be added to the bot as a helper while ### |
| 13 |
### this module is loaded. ### |
| 14 |
test_helpers = ['a_simple_helper'] |
| 15 |
|
| 16 |
### A command struct with all the variables used. ### |
| 17 |
### command1 has to be a function in the module. ### |
| 18 |
do_command1_command = {'description': "A short description", |
| 19 |
'long help': "The long help for this command. Should contain everything the user needs to know.", |
| 20 |
'arguments': [("argument1 <required> [optional]", "This is an optional argument specific help string"), |
| 21 |
"argument2 [<optional variable>]"], |
| 22 |
'public': True, |
| 23 |
'level': 0} |
| 24 |
|
| 25 |
### An alias is a simple system for expanding shorter strings into longer string or set ### |
| 26 |
### of strings. The replacement is straightforward and occurs before any other parsing. ### |
| 27 |
test_alias = {'c1': 'command1 argument1', |
| 28 |
'c': 'command1'} |
| 29 |
|
| 30 |
### Time between calling update function in seconds. ### |
| 31 |
update_test_delay = 60 |
| 32 |
update_test_time_left = 0 |
| 33 |
|
| 34 |
def init_test(bot, server, sender = None): |
| 35 |
"""Do things to initate the module and return True if |
| 36 |
successfull otherwise False.""" |
| 37 |
print " + Initiate Test module." |
| 38 |
return True |
| 39 |
|
| 40 |
def unload_test(bot, server, sender = None): |
| 41 |
"""Do something on unloading the module.""" |
| 42 |
print " + Unload Test module." |
| 43 |
return True |
| 44 |
|
| 45 |
def update_test(bot, server): |
| 46 |
"""Do this every iteration in the main-loop.""" |
| 47 |
print " * [%s] Update." % time.strftime('%H:%M:%S') |
| 48 |
|
| 49 |
def test_join_part_handler(bot, server, channel, join): |
| 50 |
"""Do this on joining or parting from a channel.""" |
| 51 |
if join: |
| 52 |
print " + Joined channel '%s'." % channel |
| 53 |
else: |
| 54 |
print " + Parted channel '%s'." % channel |
| 55 |
|
| 56 |
def test_public_msg_handler(bot, server, sender, target, msg, action = False): |
| 57 |
"""Do this on public messages from channels.""" |
| 58 |
print " + Got public message from '%s' to '%s': %s" % (irclib.nm_to_n(sender), target, msg) |
| 59 |
|
| 60 |
def test_private_msg_handler(bot, server, sender, msg, action = False): |
| 61 |
"""Do this on private messages from sender.""" |
| 62 |
print " + Got private message from '%s': %s" % (irclib.nm_to_n(sender), msg) |
| 63 |
|
| 64 |
def test_public_notice_handler(bot, server, sender, target, msg): |
| 65 |
"""Do this on private notice from sender.""" |
| 66 |
print " + Got public notice from '%s' to '%s': %s" % (irclib.nm_to_n(sender), target, msg) |
| 67 |
|
| 68 |
def test_private_notice_handler(bot, server, sender, msg): |
| 69 |
"""Do this on private notice from sender.""" |
| 70 |
print " + Got private notice from '%s': %s" % (irclib.nm_to_n(sender), msg) |
| 71 |
|
| 72 |
def test_ctcp_handler(bot, server, sender, msg): |
| 73 |
"""Do this on ctcp request from sender.""" |
| 74 |
print " + CTCP from '%s': %s" % (irclib.nm_to_n(sender), msg) |
| 75 |
|
| 76 |
def do_command1(bot, server, sender, target, args): |
| 77 |
"""For this command to be callable the do_command1_command |
| 78 |
dictionary has to be defined. |
| 79 |
|
| 80 |
Arguments: |
| 81 |
bot - The bot object |
| 82 |
server - The server object |
| 83 |
sender - The one issuing the command |
| 84 |
target - To who the command is issued, either a |
| 85 |
channel or the bot nickname. |
| 86 |
args - A list of arguments to the command.""" |
| 87 |
print "----- Test Command -----" |
| 88 |
|
| 89 |
def a_simple_helper(the, args, you, want): |
| 90 |
"""This function has no specific syntax it will just get added to the bot as a helper.""" |
| 91 |
print "----- This will help you -----" |