<commit_before><commit_msg>example module<commit_after># -*- coding: utf-8 -*-
import configs.module


#This function returns the module data.
#You can also use init(server),
#this will pass the server when the module registers.
def init():
    #Create the class, the argument is the name of the module.
    #It is important to keep the name of the module the same as the file.
    m = configs.module.Module('module')
    #This function sets the module help, returned by modhelp
    m.set_help('An example module.')

    ###

    #Modules interact with the rest of the bot by means of hooks
    #There are several kinds of hooks

    ##

    #Base hooks are called on server events
    #This hook is called upon any IRC message
    m.add_base_hook('recv', recv)
    #This hook is called upon the end of the MOTD
    m.add_base_hook('joined', joined)

    ##

    #Timed hooks are called on a timer
    #The timer is not exact
    m.add_timer_hook(10 * 1000, tensecondtimer)

    ##

    #Command hooks are processed by the commands module
    #They define regular commands such as echo or google
    m.add_command_hook('example',
        {
            #Help text to be displayed with help
            'help': 'An example command, echoes text.',
            #Required access level, if ommitted defaults to 0
            'level': 0,
            #Function to call
            'function': example,
            #Argument definitions
            'args': [
                {
                    #Name of the argument
                    'name': 'arg1',
                    #Help text
                    'help': 'Echo this.',
                    #Optional?
                    'optional': False,
                    },
                {
                    #Name of the argument
                    'name': 'arg2',
                    #Help text
                    'help': 'Echo this if it exists.',
                    #Optional?
                    'optional': True,
                    #If end is True, then anything after the last non-end
                    #will be put into this
                    'end': True,
                    }
                ]
            }
        )
    return m


def recv(fp):
    #The recv base hook is passed a fullparse object
    #A fullparse object contains a splitparse object and a server reference
    print(('Received: ' + fp.sp.message))


def joined(server):
    #The joined base hook is passed a server object
    print(('Ready!'))


def tensecondtimer():
    print('Ten seconds have passed.')


def example(fp, args):
    #Return a message with arg1 (no default) and arg2 (default empty string)
    return args.getlinstr('arg1') + ' -- ' + args.getlinstr('arg2', '')
{'fraction_non_alphanumeric': 0.08604135893648449, 'fraction_numerical': 0.005539143279172821, 'mean_word_length': 1.7171514543630892, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3348151', 'n_tokens_mistral': 728, 'n_tokens_neox': 685, 'n_words': 289}