### PluginDownloader Command Examples Source: https://docs.limnoria.net/_sources/use/plugins/PluginDownloader.rst.txt Demonstrates the usage of PluginDownloader commands for listing repositories, listing plugins, getting plugin info, and installing a plugin. ```text < Mikaela> @load PluginDownloader < Limnoria> Ok. < Mikaela> @plugindownloader repolist < Limnoria> Antibody, jlu5, Hoaas, Iota, progval, SpiderDave, boombot, code4lib, code4lib-edsu, code4lib-snapshot, doorbot, frumious, jonimoose, mailed-notifier, mtughan-weather, nanotube-bitcoin, nyuszika7h, nyuszika7h-old, pingdom, quantumlemur, resistivecorpse, scrum, skgsergio, stepnem < Mikaela> @plugindownloader repolist progval < Limnoria> AttackProtector, AutoTrans, Biography, Brainfuck, ChannelStatus, Cleverbot, Coffee, Coinpan, Debian, ERepublik, Eureka, Fortune, GUI, GitHub, Glob2Chan, GoodFrench, I18nPlaceholder, IMDb, IgnoreNonVoice, Iwant, Kickme, LimnoriaChan, LinkRelay, ListEmpty, Listener, Markovgen, MegaHAL, MilleBornes, NoLatin1, NoisyKarma, OEIS, PPP, PingTime, Pinglist, RateLimit, Rbls, Redmine, Scheme, Seeks, (1 more message) < Mikaela> more < Limnoria> SilencePlugin, StdoutCapture, Sudo, SupyML, SupySandbox, TWSS, Trigger, Trivia, Twitter, TwitterStream, Untiny, Variables, WebDoc, WebLogs, WebStats, Website, WikiTrans, Wikipedia, WunderWeather < Mikaela> @plugindownloader info progval Wikipedia < Limnoria> Grabs data from Wikipedia. < Mikaela> @plugindownloader install progval Wikipedia < Limnoria> Ok. < Mikaela> @load Wikipedia < Limnoria> Ok. ``` -------------------------------- ### Install Plugin from PyPI Source: https://docs.limnoria.net/_sources/develop/plugin_distribution.rst.txt Example command for users to install your published plugin using pip. This requires root privileges. ```bash sudo pip3 install limnoria-yourplugin ``` -------------------------------- ### Interactive Plugin Configuration Example Source: https://docs.limnoria.net/_sources/develop/advanced_plugin_config.rst.txt An example of a 'configure' function that uses supybot.questions for interactive plugin setup, including yes/no questions and text input. ```python def configure(advanced): # This will be called by supybot to configure this module. advanced is # a bool that specifies whether the user identified himself as an advanced # user or not. You should effect your configuration by manipulating the # registry as appropriate. from supybot.questions import expect, anything, something, yn WorldDom = conf.registerPlugin('WorldDom', True) if yn("""The WorldDom plugin allows for total world domination with simple commands. Would you like these commands to be enabled for everyone?""", default=False): WorldDom.globalWorldDominationRequires.setValue("") else: cap = something("""What capability would you like to require for this command to be used?""", default="Admin") WorldDom.globalWorldDominationRequires.setValue(cap) dir = expect("""What direction would you like to attack from in your quest for world domination?""", ["north", "south", "east", "west", "ABOVE"], default="ABOVE") WorldDom.attackDirection.setValue(dir) ``` -------------------------------- ### setup.py with external dependencies Source: https://docs.limnoria.net/_sources/develop/plugin_distribution.rst.txt Example of a setup.py file that includes external Python packages as dependencies for the plugin. These will be installed automatically by pip. ```python from supybot.setup import plugin_setup plugin_setup( 'YourPlugin', install_requires=[ 'requests', ], ) ``` -------------------------------- ### Get Help on a Configuration Option Source: https://docs.limnoria.net/_sources/use/configuration.rst.txt Use 'config help' followed by the option path to get a detailed explanation of a configuration variable. This example shows help for 'supybot.snarfThrottle'. ```irc @config help supybot.snarfThrottle jemfinch: A floating point number of seconds to throttle snarfed URLs, in order to prevent loops between two bots snarfing the same URLs and having the snarfed URL in the output of the snarf message. (Current value: 10.0) ``` -------------------------------- ### Install LinkRelay plugin from GitHub via pip Source: https://docs.limnoria.net/develop/plugin_distribution.html An example of installing a specific plugin (LinkRelay) from a GitHub repository that contains multiple plugins, using pip. ```bash pip3 install "git+https://github.com/progval/Supybot-plugins.git#subdirectory=LinkRelay" ``` -------------------------------- ### Run Limnoria Setup Wizard Source: https://docs.limnoria.net/use/install.html Execute the supybot-wizard command to configure Limnoria. This command guides you through the initial setup process, including creating configuration files and setting up an owner user. ```bash supybot-wizard ``` -------------------------------- ### Install LinkRelay plugin from GitHub using pip Source: https://docs.limnoria.net/_sources/develop/plugin_distribution.rst.txt This is a concrete example of installing a specific plugin (LinkRelay) from a public GitHub repository using pip, specifying the subdirectory. ```bash pip3 install "git+https://github.com/progval/Supybot-plugins.git#subdirectory=LinkRelay" ``` -------------------------------- ### Plugin Test Case Setup with setUp() Source: https://docs.limnoria.net/develop/advanced_plugin_testing.html Extends a plugin test case by overriding the `setUp` method to perform custom initialization. This includes setting the user's prefix and feeding initial messages to the simulated IRC network. ```python def setUp(self): # Important! This sets up the bot's simulated IRC network for testing super().setUp() # Define the identity of the user who we send messages as self.prefix = 'foo!bar@baz' # Send a message to the simulated IRC network, in this case to register # an account with the bot. self.nick refers to the bot's nick. self.feedMsg('register tester moo', to=self.nick, frm=self.prefix) m = self.getMsg(' ') # Get the response for the last command ``` -------------------------------- ### Plugin Test Case with Setup Source: https://docs.limnoria.net/_sources/develop/advanced_plugin_testing.rst.txt Shows how to override the setUp() method to perform custom setup actions for plugin tests, such as defining user prefixes and feeding initial messages. ```python def setUp(self): # Important! This sets up the bot's simulated IRC network for testing super().setUp() # Define the identity of the user who we send messages as self.prefix = 'foo!bar@baz' # Send a message to the simulated IRC network, in this case to register # an account with the bot. self.nick refers to the bot's nick. self.feedMsg('register tester moo', to=self.nick, frm=self.prefix) m = self.getMsg(' ') # Get the response for the last command ``` -------------------------------- ### Install Plugin from PyPI Source: https://docs.limnoria.net/develop/plugin_distribution.html Install your published plugin using pip. ```bash sudo pip3 install limnoria-yourplugin ``` -------------------------------- ### Setup virtualenv for Limnoria (pip) Source: https://docs.limnoria.net/_sources/use/install.rst.txt Create and activate a Python virtual environment for installing Limnoria manually using pip. This isolates the installation. ```bash mkdir -p $HOME/.venvs/ python3 -m venv $HOME/.venvs/limnoria . $HOME/.venvs/limnoria/bin/activate ``` -------------------------------- ### Install a plugin using PluginDownloader Source: https://docs.limnoria.net/_sources/develop/plugin_distribution.rst.txt If a plugin repository is added to Limnoria's known repositories, users can install it with a single command. ```bash @plugindownloader install Jdoe ``` -------------------------------- ### Install pipx and ensure path Source: https://docs.limnoria.net/_sources/use/install.rst.txt Install the pipx tool and ensure its executable path is set up, typically on Debian/Ubuntu systems. ```bash sudo apt update sudo apt install pipx pipx ensurepath ``` -------------------------------- ### Install Limnoria using emerge (Gentoo) Source: https://docs.limnoria.net/_sources/use/install.rst.txt Install Limnoria on Gentoo systems using the emerge package manager. ```bash sudo emerge net-irc/limnoria ``` -------------------------------- ### Install Twine Source: https://docs.limnoria.net/develop/plugin_distribution.html Install the twine package, a tool for uploading Python packages to PyPI. ```bash python3 -m pip install --user --upgrade twine ``` -------------------------------- ### Install a plugin from a Git repository using pip Source: https://docs.limnoria.net/_sources/develop/plugin_distribution.rst.txt Users can install a plugin directly from a Git repository using pip. This method also handles the installation of plugin dependencies. ```bash pip3 install git+https://example.org/~jdoe/YourPlugin.git ``` -------------------------------- ### Pagination Example with 'more' Command Source: https://docs.limnoria.net/use/getting_started.html Demonstrates how to use the '$more' command to view subsequent chunks of a paginated message. The example shows a conversation flow involving a long response and the user requesting more. ```text $config default supybot.replies.genericNoCapability jemfinch: You're missing some capability you need. This could be because you actually possess the anti-capability for the capability that's required of you, or because the channel provides that anti-capability by default, or because the global capabilities include that anti-capability. Or, it could be because the channel or the global defaultAllow is set to False, meaning (1 more message) $more jemfinch: that no commands are allowed unless explicitly in your capabilities. Either way, you can't do what you want to do. ``` -------------------------------- ### Install plugin using PluginDownloader Source: https://docs.limnoria.net/develop/plugin_distribution.html If a plugin repository is added to Limnoria's known repositories, users can install plugins with a single command using the @plugindownloader command. ```bash @plugindownloader install Jdoe ``` -------------------------------- ### Install Twine for Publishing Source: https://docs.limnoria.net/_sources/develop/plugin_distribution.rst.txt Install the twine package, a tool for uploading Python packages to PyPI. This command should be run as a user. ```bash python3 -m pip install --user --upgrade twine ``` -------------------------------- ### Start Supybot with Configuration File Source: https://docs.limnoria.net/_sources/use/install.rst.txt Run this command from the 'runbot' directory to start your Supybot using its configuration file. Ensure you replace 'yourbotnick' with your bot's chosen nickname. ```bash supybot yourbotnick.conf ``` -------------------------------- ### Install User-Contributed Plugins Source: https://docs.limnoria.net/use/faq.html Manage user-contributed plugins using the PluginDownloader plugin. Use 'repolist' to see available repositories and 'install' to add plugins. ```bash load PluginDownloader repolist install ``` -------------------------------- ### Google Translate Command Example Source: https://docs.limnoria.net/_sources/use/plugins/Google.rst.txt Example of how to use the translate command. Requires specifying source and target language codes. ```text !translate en ar test ``` -------------------------------- ### Install Limnoria using Guix Source: https://docs.limnoria.net/_sources/use/install.rst.txt Install Limnoria on Guix or GuixSD systems using the guix package manager. ```bash guix package --install limnoria ``` -------------------------------- ### Get Help for Commands Source: https://docs.limnoria.net/_sources/use/getting_started.rst.txt Use the help command to get information about plugins and commands. Arguments in chevrons are required, and arguments in square brackets are optional. ```text help help PluginName help PluginName CommandName help CommandName ``` -------------------------------- ### Install single plugin via pip Source: https://docs.limnoria.net/develop/plugin_distribution.html Users can install a single plugin directly from a VCS repository using pip. This method also handles the installation of the plugin's dependencies. ```bash pip3 install git+https://example.org/~jdoe/YourPlugin.git ``` -------------------------------- ### Install Limnoria using dnf (Fedora) Source: https://docs.limnoria.net/_sources/use/install.rst.txt Install Limnoria on Fedora systems using the dnf package manager. ```bash sudo dnf install limnoria ``` -------------------------------- ### Install Limnoria using apt (Debian/Ubuntu) Source: https://docs.limnoria.net/_sources/use/install.rst.txt Use this command to install Limnoria if you are on a Debian or Ubuntu-based system. Note that stable releases might not have the latest features. ```bash sudo apt-get install limnoria ``` -------------------------------- ### Install Limnoria and Requirements Source: https://docs.limnoria.net/_sources/use/install_windows.rst.txt Installs Limnoria and its dependencies using pip. Ensure you are running cmd.exe as Administrator. ```bat python3 -m pip install -r https://raw.githubusercontent.com/ProgVal/Limnoria/master/requirements.txt --upgrade python3 -m pip install limnoria --upgrade ``` -------------------------------- ### Install optional dependencies for Limnoria (pip) Source: https://docs.limnoria.net/_sources/use/install.rst.txt Install optional dependencies for Limnoria from a requirements file into an active virtual environment using pip. ```bash pip install -r https://raw.githubusercontent.com/progval/Limnoria/master/requirements.txt --upgrade ``` -------------------------------- ### Install a specific plugin from a multi-plugin repository using pip Source: https://docs.limnoria.net/_sources/develop/plugin_distribution.rst.txt When a repository contains multiple plugins, users can specify a subdirectory to install a particular plugin using pip. ```bash pip3 install "git+https://example.org/~jdoe/Supybot-plugins.git#subdirectory=YourPlugin" ``` -------------------------------- ### Install Limnoria using yum (CentOS/RHEL) Source: https://docs.limnoria.net/_sources/use/install.rst.txt Install Limnoria on CentOS or RHEL systems. Ensure the EPEL repository is added first. ```bash sudo yum install limnoria ``` -------------------------------- ### Install Limnoria using pip Source: https://docs.limnoria.net/_sources/use/install.rst.txt Install Limnoria into an active virtual environment using pip. Ensure you are in the correct virtualenv before running. ```bash pip install limnoria --upgrade ``` -------------------------------- ### Start Limnoria Bot Source: https://docs.limnoria.net/_sources/use/install_windows.rst.txt Starts the Limnoria bot using its configuration file. This command should be run from within the bot's runbot directory. ```bat python3 C:\Python311\Scripts\supybot yourbotnick.conf ``` -------------------------------- ### Registering Limnoria Plugin Source: https://docs.limnoria.net/develop/plugin_tutorial.html Register a new plugin with Limnoria's configuration registry. This example shows how to register the 'Random' plugin and provides a commented-out example for registering a global configuration value. ```python Random = conf.registerPlugin('Random') # This is where your configuration variables (if any) should go. For example: # conf.registerGlobalValue(Random, 'someConfigVariableName', # registry.Boolean(False, _("""Help for someConfigVariableName."""'))) ``` -------------------------------- ### Join Command Syntax Examples Source: https://docs.limnoria.net/use/getting_started.html Shows how to use the 'join' command, which requires a channel name and optionally accepts a channel key. ```text join [] ``` ```text join #limnoria ``` ```text join #limnoria MySecretKey ``` -------------------------------- ### Use 'trout' Aka Source: https://docs.limnoria.net/_sources/use/plugins/Aka.rst.txt Example of using the 'trout' Aka with an argument. This demonstrates how aliases with arguments are invoked. ```text @trout me * bot slaps me with a large trout ``` -------------------------------- ### Get Plugin Help Source: https://docs.limnoria.net/_modules/supybot/callbacks.html Retrieves the docstring of the plugin if available, otherwise returns None. ```python def getPluginHelp(self): if hasattr(self, '__doc__'): return self.__doc__ else: return None ``` -------------------------------- ### Help Command Syntax Examples Source: https://docs.limnoria.net/use/getting_started.html Demonstrates various ways to use the 'help' command with optional plugin and command arguments. Square brackets indicate optional parameters. ```text help [] [] ``` ```text help ``` ```text help PluginName ``` ```text help PluginName CommandName ``` ```text help CommandName ``` -------------------------------- ### Get Default Configuration Value Source: https://docs.limnoria.net/_sources/use/configuration.rst.txt Use 'config default' followed by the option path to retrieve the default value for a configuration variable. This example gets the default for 'supybot.reply.whenAddressedBy.chars'. ```irc @config default supybot.reply.whenAddressedBy.chars jemfinch: '' ``` -------------------------------- ### Minimal setup.py for a Limnoria plugin Source: https://docs.limnoria.net/_sources/develop/plugin_distribution.rst.txt This is the most basic setup.py file required for a plugin to be installable via pip. It uses supybot.setup.plugin_setup to handle most configurations. ```python from supybot.setup import plugin_setup plugin_setup( 'YourPlugin', ) ``` -------------------------------- ### SupystoryServerCallback for GET Requests Source: https://docs.limnoria.net/develop/httpserver.html This callback class handles GET requests by checking the URI path and returning specific responses or HTML content. It serves as an example for creating custom HTTP request handlers. ```python class SupystoryServerCallback(httpserver.SupyHTTPServerCallback): name = 'Supystory' defaultResponse = """ This plugin handles only GET request, please don't use other requests. """ def doGet(self, handler, path): if path == '/supybot': response = b'Supybot is the best IRC bot ever.' elif path == '/gribble': response = b'Thanks to Gribble, we have many bug fixes and SQLite 3 support' elif path == '/limnoria': response = b'Thanks to Limnoria, you can to internationalize your plugins and write a web server.' elif path == '' or path == '/': handler.send_response(200) # Found handler.send_header('Content-type', 'text/html') # This is the MIME for HTML data handler.end_headers() # We won't send more headers handler.wfile.write(b""" Supystory

Supystory

Here are some links you can visit: Supybot Gribble Limnoria

") return else: handler.send_response(404) # Not found handler.send_header('Content-type', 'text/html') # This is the MIME for HTML data handler.end_headers() # We won't send more headers handler.wfile.write(b""" Error

404 Not found

The document could not be found. Try one of this links: Supybot Gribble Limnoria

") return handler.send_response(200) handler.send_header('Content-type', 'text/plain') # This is the MIME for plain text handler.end_headers() # We won't send more headers handler.wfile.write(response) ``` -------------------------------- ### List Configuration Options Source: https://docs.limnoria.net/_sources/use/configuration.rst.txt Use 'config list' to see all configuration options within a specific group. This example shows options under 'supybot'. ```irc @config list supybot #alwaysJoinOnInvite, @abuse, @capabilities, @commands, @databases, @debug, @directories, @drivers, @log, @networks, @nick, @plugins, @protocols, @replies, @reply, @servers, defaultIgnore, defaultSocketTimeout, externalIP, flush, followIdentificationThroughNickChanges, ident, language, pidFile, snarfThrottle, upkeepInterval, and user ``` -------------------------------- ### Periodic Event Scheduling Example Source: https://docs.limnoria.net/_sources/develop/schedule.rst.txt This example demonstrates how to schedule a periodic event that sends a message to a specific channel at a set interval. It includes setup for removing existing events and defining a helper function to call the event method. ```python ### # This is an example plugin that sends a message to a channel every 60 seconds, # includes commands to stop, start, and reset the spammer, and a command to # schedule a one-off event ### # these are the default plugin modules import supybot.utils as utils from supybot.commands import * import supybot.plugins as plugins import supybot.ircutils as ircutils import supybot.callbacks as callbacks # these are the extra modules we'll be using import time import supybot.ircmsgs as ircmsgs import supybot.schedule as schedule class Spam(callbacks.Plugin): """Add the help for "@plugin help Spam" here This should describe *how* to use this plugin.""" def __init__(self, irc): super().__init__(irc) # this is the channel we want to spam, and how frequently we want to do it. # It would be nicer to put it in a supybot config variable instead, but for # this demonstration, defining it in the plugin itself is fine. self.spamChannel = '#testytest' self.spamTime = 60 # scheduler events are global, so we want to test to make sure the event doesn't # already exist. That is, even if the plugin is reloaded, the event sticks # around. That means that you also have to be a little careful with your # event names, especially if you have multiple plugins adding events. It also # means that events will stick around even if the plugin they originated in # is unloaded. I don't know how to delete them automatically on an unload, but # it's not normally an issue. Just make sure to stop the event before unloading # the plugin if that's what you want. try: schedule.removeEvent('mySpamEvent') except KeyError: pass # now that we know there's no event by that name scheduled, we can create one. # but first, we need to define a local helper function that will do the thing # that we want. You can put the full contents into here, but I prefer to use # separate methods, as it makes the code easier to get around in. We need # the helper function because when you add events, you can't include arguments. def myEventCaller(): self.spamEvent(irc) # and now we can schedule the actual event # schedule.addPeriodicEvent(f, t, name=None, now=True) # f is the method, t is the time in seconds, name gives it a name and is optional # (but highly recommended, so that you can refer to the event in the future. # otherwise, it's easy to accumulate duplicate events), and 'now' specifies # whether to perform the action immediately, or to wait until time is up to # perform it for the first time. Default is True. schedule.addPeriodicEvent(myEventCaller, self.spamTime, 'mySpamEvent') self.irc = irc # make sure to have a capital letter or underscore or something, as it's not a method # that we want turned into an IRC command def spamEvent(self, irc): # we need to use queueMsg() rather than reply(), because when the event is # scheduled on loading the plugin (as opposed to scheduling it with one of the # commands that we'll define next), it recieves its irc object from __init__(). # When the bot is started, the irc object that comes from __init__() doesn't # include a reply() method, because it's not loading in response to a command; # it's loading on the bot startup. If you don't want your event to be scheduled # automatically and so don't schedule it from __init__(), but only from an IRC # command, then it's safe to use irc.reply(), as there are no circumstances # under which the irc object won't have a reply() method. irc.queueMsg(ircmsgs.privmsg(self.spamChannel, 'I\'m spamming the channel!')) def start(self, irc, msg, args): """takes no arguments A command to start the spammer.""" # don't forget to redefine the event wrapper def myEventCaller(): self.spamEvent(irc) try: schedule.addPeriodicEvent(myEventCaller, self.spamTime, 'mySpamEvent', False) except AssertionError: irc.reply('Error: the spammer was already running!') else: irc.reply('Spammer started!') start = wrap(start) def stop(self, irc, msg, args): """takes no arguments A command to stop the spammer.""" try: schedule.removeEvent('mySpamEvent') ``` -------------------------------- ### Run Supybot Wizard for Configuration Source: https://docs.limnoria.net/_sources/use/install_windows.rst.txt Launches the supybot-wizard to guide through the bot configuration process. This script is located in the Python installation's Scripts directory. ```bat python3 C:\Python311\Scripts\supybot-wizard ``` -------------------------------- ### Nginx Reverse Proxy Configuration Source: https://docs.limnoria.net/_sources/use/httpserver.rst.txt Example Nginx configuration for proxying requests to Limnoria's HTTP server. This setup assumes a new site configuration in /etc/nginx/sites-enabled/bot. ```nginx server { # Note that your default server should specify these ports listen 80; listen [::]:80; # If your default server also has HTTPS configured, uncomment # the following two listen lines to enable it for this vhost. #listen 443; #listen [::]:443; server_name stats.yourdomain.org; location / { proxy_pass http://localhost:8080/; } } ``` -------------------------------- ### Get Configuration Value Source: https://docs.limnoria.net/_sources/use/configuration.rst.txt Fetch the current value of a configuration variable by running the 'config' command with the variable's full path. This example retrieves the value for 'supybot.reply.whenAddressedBy.chars'. ```irc @config supybot.reply.whenAddressedBy.chars jemfinch: '@' ``` -------------------------------- ### Create a Simple Command with Aka Source: https://docs.limnoria.net/_sources/use/faq.rst.txt Use the Aka plugin to create simple commands. This example creates a 'rules' command that echoes predefined rules. Assumes the Utilities plugin is loaded. ```text @aka add "rules" "echo Here are the rules of the channel." ``` -------------------------------- ### Handle GET Requests for Different Paths Source: https://docs.limnoria.net/_sources/develop/httpserver.rst.txt Implements the `doGet` method to provide specific responses based on the requested URL path. This example handles requests for '/supybot', '/gribble', '/limnoria', the root path, and returns a 404 for any other path. ```python class SupystoryServerCallback(httpserver.SupyHTTPServerCallback): name = 'Supystory' defaultResponse = """ This plugin handles only GET request, please don't use other requests.""" def doGet(self, handler, path): if path == '/supybot': response = b'Supybot is the best IRC bot ever.' elif path == '/gribble': response = b'Thanks to Gribble, we have many bug fixes and SQLite 3 support' elif path == '/limnoria': response = b'Thanks to Limnoria, you can to internationalize your plugins and write a web server.' elif path == '' or path == '/': handler.send_response(200) # Found handler.send_header('Content-type', 'text/html') # This is the MIME for HTML data handler.end_headers() # We won't send more headers handler.wfile.write(b""" Supystory

Supystory

Here are some links you can visit: Supybot Gribble Limnoria

""") return else: handler.send_response(404) # Not found handler.send_header('Content-type', 'text/html') # This is the MIME for HTML data handler.end_headers() # We won't send more headers handler.wfile.write(b""" Error

404 Not found

The document could not be found. Try one of this links: Supybot Gribble Limnoria

""") return handler.send_response(200) handler.send_header('Content-type', 'text/plain') # This is the MIME for plain text handler.end_headers() # We won't send more headers handler.wfile.write(response) ``` -------------------------------- ### Configure Limnoria to load plugins from a directory Source: https://docs.limnoria.net/_sources/develop/plugin_distribution.rst.txt After cloning a repository with multiple plugins, users must configure Limnoria to recognize the new plugin directory. ```bash @config supybot.directories.plugins [config supybot.directories.plugins], /home/me/JdoePlugins ``` -------------------------------- ### Registering a Bot with NickServ (Atheme 7.x) Source: https://docs.limnoria.net/_sources/use/identifying_to_services.rst.txt Use this command to register your bot's account with NickServ. Ensure you replace 'mypassword' and 'bot@example.com' with your desired credentials. ```irc load Services nickserv register mypassword bot@example.com ``` -------------------------------- ### Install Limnoria using pipx Source: https://docs.limnoria.net/_sources/use/install.rst.txt Install Limnoria globally using the pipx tool. This isolates the application and its dependencies. ```bash pipx install limnoria ``` -------------------------------- ### Initialize and Open User Database Source: https://docs.limnoria.net/_modules/supybot/ircdb.html Initializes a UsersDictionary and opens the user database file. Handles potential EnvironmentError during file opening. ```python confDir = conf.supybot.directories.conf() try: userFile = os.path.join(confDir, conf.supybot.databases.users.filename()) users = UsersDictionary() users.open(userFile) except EnvironmentError as e: log.warning('Couldn\'t open user database: %s', e) ``` -------------------------------- ### List Configuration Options Source: https://docs.limnoria.net/use/configuration.html Lists all configuration options within a specified group. Use this to explore available settings. ```irc commands @config list supybot ``` -------------------------------- ### Initialize Registry from File Source: https://docs.limnoria.net/_modules/supybot/registry.html Loads the bot's configuration from a specified file into memory. Handles line continuations and basic parsing of key-value pairs. Clears existing cache if `clear` is True. ```python def open_registry(filename, clear=False): """Initializes the module by loading the registry file into memory.""" global _lastModified if clear: _cache.clear() _fd = open(filename, encoding='utf8') fd = utils.file.nonCommentNonEmptyLines(_fd) acc = '' slashEnd = re.compile(r'\\*$') for (lineno, line) in enumerate(fd): line = line.rstrip('\r\n') # XXX There should be some way to determine whether or not we're # starting a new variable or not. As it is, if there's a backslash # at the end of every line in a variable, it won't be read, and # worse, the error will pass silently. # # If the line ends in an odd number of backslashes, then there is a # line-continuation. m = slashEnd.search(line) if m and len(m.group(0)) % 2: acc += line[:-1] continue else: acc += line try: (key, value) = re.split(r'(? @echo hello world hello world ``` -------------------------------- ### Handle MOTD Start Source: https://docs.limnoria.net/_modules/supybot/irclib.html Callback for the start of the Message of the Day (MOTD) from the IRC server. It initiates the FSM state for MOTD. ```python def do375(self, msg): self.state.fsm.on_start_motd(self, msg) log.info('Got start of MOTD from %s', self.server) ``` -------------------------------- ### setup.py overriding the package name Source: https://docs.limnoria.net/_sources/develop/plugin_distribution.rst.txt This setup.py demonstrates how to override the default package name (e.g., 'limnoria-yourplugin') if a different name is desired for distribution on PyPI. ```python from supybot.setup import plugin_setup plugin_setup( 'YourPlugin', name='limnoria-this-is-my-plugin', ) ``` -------------------------------- ### Basic Plugin Test Case Example Source: https://docs.limnoria.net/_sources/develop/advanced_plugin_testing.rst.txt Demonstrates the structure of a basic plugin test case, including class declaration, plugin loading, and a simple test method. ```python class MyPluginTestCase(PluginTestCase): # List of plugins to load plugins = ('MyPlugin',) def testEcho(self): # Replace the command and expected response with your own, # add other assertions, etc. self.assertResponse('echo Hello world', 'Hello world') def testSomethingElse(self): # Add another test case here ``` -------------------------------- ### Get Channel or None Source: https://docs.limnoria.net/_modules/supybot/commands.html Attempts to get the channel for the command. If an ArgumentError occurs (e.g., not in a channel), it appends None to the state's arguments. ```python def getChannelOrNone(irc, msg, args, state): try: getChannel(irc, msg, args, state) except callbacks.ArgumentError: state.args.append(None) ``` -------------------------------- ### Define 'kick' command with multiple state-checking converters Source: https://docs.limnoria.net/develop/using_wrap.html This example demonstrates a more complex command definition using several converters for state checking, including permissions and participant validation. It ensures the bot has necessary privileges and that specified nicks are in the channel. ```python @wrap(['op', ('haveHalfop+', _('kick someone')), commalist('nickInChannel'), additional('text')]) def kick(self, irc, msg, args, channel, nicks, reason): """[] [, , ...] [] Kicks (s) from for . If isn't given, uses the nick of the person making the command as the reason. is only necessary if the message isn't sent in the channel itself. """ # ... ``` -------------------------------- ### Get canonical capability form Source: https://docs.limnoria.net/_modules/supybot/ircdb.html Returns the lowercase version of a capability. If the input is a callable, it's called first to get the capability string. ```python def canonicalCapability(capability): if callable(capability): capability = capability() assert isCapability(capability), 'got %s' % capability return capability.lower() ``` -------------------------------- ### Initialize and Open Channel Database Source: https://docs.limnoria.net/_modules/supybot/ircdb.html Initializes a ChannelsDictionary and opens the channel database file. Handles potential EnvironmentError during file opening. ```python confDir = conf.supybot.directories.conf() try: channelFile = os.path.join(confDir, conf.supybot.databases.channels.filename()) channels = ChannelsDictionary() channels.open(channelFile) except EnvironmentError as e: log.warning('Couldn\'t open channel database: %s', e) ``` -------------------------------- ### Install Limnoria from AUR (Arch Linux) Source: https://docs.limnoria.net/_sources/use/install.rst.txt Install Limnoria on Arch Linux from the AUR. Choose either the stable release or the git snapshot version. ```bash limnoria ``` ```bash limnoria-git ``` -------------------------------- ### Initialize and Open Network Database Source: https://docs.limnoria.net/_modules/supybot/ircdb.html Initializes a NetworksDictionary and opens the network database file. Handles potential EnvironmentError during file opening. ```python confDir = conf.supybot.directories.conf() try: networkFile = os.path.join(confDir, conf.supybot.databases.networks.filename()) networks = NetworksDictionary() networks.open(networkFile) except EnvironmentError as e: log.warning('Couldn\'t open network database: %s', e) ``` -------------------------------- ### Load Alias and Aka Plugins Source: https://docs.limnoria.net/_sources/use/plugins/Aka.rst.txt Before using Aka, load the Alias and Aka plugins. This is a prerequisite for importing alias databases. ```text @load Alias @load Aka ``` -------------------------------- ### Check Limnoria Executable Path and Interpreter Source: https://docs.limnoria.net/_sources/asking-for-help.rst.txt When the bot fails to start, run these commands in the same shell to identify the Limnoria executable path and the interpreter it uses. This information is crucial for diagnosing startup issues. ```shell which limnoria head -n 1 $(which limnoria) ``` -------------------------------- ### Clone a single plugin repository Source: https://docs.limnoria.net/_sources/develop/plugin_distribution.rst.txt Users can clone a single plugin from a VCS repository to install it. Ensure the user has the VCS client and any plugin dependencies installed. ```bash cd runbot/plugins/ git clone https://example.org/~jdoe/YourPlugin.git ``` -------------------------------- ### Get Help for Identify Command Source: https://docs.limnoria.net/_sources/use/getting_started.rst.txt This snippet shows how to get help for the 'identify' command, which is used for logging into the bot. It highlights that this command must be sent privately. ```irc help identify (identify ) -- Identifies the user as . This command (and all other commands that include a password) must be sent to the bot privately, not in a channel. ``` -------------------------------- ### Configure plugin directory Source: https://docs.limnoria.net/develop/plugin_distribution.html After cloning a repository with multiple plugins, users need to configure their bot to recognize the new plugin directory. ```bash @config supybot.directories.plugins [config supybot.directories.plugins], /home/me/JdoePlugins ``` -------------------------------- ### Implementing GET request handling Source: https://docs.limnoria.net/_sources/develop/httpserver.rst.txt Implement the `doGet` method in your callback class to handle GET requests. This method receives the handler and the requested path as arguments. ```python class SupystoryServerCallback(httpserver.SupyHTTPServerCallback): name = 'Supystory' defaultResponse = """ This plugin handles only GET request, please don't use other requests." """ def doGet(self, handler, path): if path == '/supybot': response = b'Supybot is the best IRC bot ever.' ``` -------------------------------- ### Load and Configure Services Plugin Source: https://docs.limnoria.net/_sources/use/identifying_to_services.rst.txt Loads the Services plugin and configures it to recognize NickServ and ChanServ. This allows the bot to identify using the Services plugin. ```bash load Services ``` ```bash config network [] plugins.services.nickserv NickServ ``` ```bash config network [] plugins.services.chanserv ChanServ ``` -------------------------------- ### Get Help for a Command Source: https://docs.limnoria.net/_sources/use/getting_started.rst.txt Use the 'help ' command to get detailed information about a specific command. If a command exists in multiple plugins, you can specify the plugin name. ```irc supybot: help help (help [] []) -- This command gives a useful description of what does. is only necessary if the command is in more than one plugin. You may also want to use the 'list' command to list all available plugins and commands. ``` ```irc supybot: help list (list [--unloaded] []) -- Lists the commands available in the given plugin. If no plugin is given, lists the public plugins available. If --unloaded is given, it will list available plugins that are not loaded. ``` ```irc supybot: help load (load ) -- Loads the plugin from any of the directories in conf.supybot.directories.plugins; usually this includes the main installed directory and 'plugins' in the current directory. ```