Package: lurklite
lurkliteluk3yx's "lightweight™" IRC and Discord bot (excluding commands).Official botIf you can't or don't want to run your own bot, you can request that the
official bot be added to your channel. The official bot is on a few IRC
networks, most notably Libera Chat and xeroxIRC. PMluk3yxthere if you want
the bot on an IRC channel you own.Note that this IRC bot is runningSopeland not lurklite, hopefully I'll
release the API shim it uses sometime.Alternatively, if you use Discord, you can usehttps://bit.ly/lurkdiscordto
add lurklite (without any permissions) to your Discord guild/server.InstallationTo install lurklite, you can simply install it withpipx install lurklite.
After installation, you should be able to runlurklite.Config fileThe lurklite config file has a format similar toinifiles. It must have a[core]section with the following values:[core]# The tempcmd db, commands added with .tempcmd are stored here.# If you have msgpack installed, this database will be slightly smaller and#   faster to read/write to/from.command_db=/path/to/tempcmd/database# The bot's command prefix.prefix=.# (Optional) A list of hostmasks to ignore.# ignored  = *!*@*/bot/*, baduser!*@*# (Optional) Disable "Yay!" and "Ouch." replies.# disable_yay  = false# disable_ouch = falseConnecting to IRC serversYou can then create sections starting withirc.(for exampleirc.mynetwork)
to connect to IRC servers:[irc.mynetwork]ip=irc.example.comport=6697nick=testbotchannels=#botwar,#other-channel# List of hostmasks to ignore (optional)# ignored = *!*@*/bot/*, *!*sopel*@*# List of hostnames for admins# admins = unaffiliated/userThe following optional values may be added to the above config, and are sent
directly tominiirc:connect_modes=+gident=identns_identity=username passwordquit_message=Quit messagerealname=realnamessl=trueConnecting to Matrix serversYou can connect to Matrix (usingminiirc_matrix) with this config section:[matrix]homeserver=example.comtoken=your-matrix-tokenadmins=@yourusername:example.comObtaining a token is currently not very straightforward. You can use the
following Python code. Note that if you execute this in an interactive Python
shell it will likely save both the username and password in its history file.importminiirc_matrixprint(miniirc_matrix.login('example.com','botusername','password'))The bot will automatically accept invites from admins.Connecting to Discord serversYou can also connect to Discord servers (viaminiirc_discord) with the
following config section:[discord]# You need miniirc_discord installed for this to work.token=your-discord-token# Using user IDs instead of username#discriminator improves security.# admins = username#1234, useridYou can only have one Discord connection per bot process, and lurklite will use
slightly more RAM if[discord]exists, asminiirc_discordwill be imported
(and if you don't specify a Discord bot token,miniirc_discordwon't be
imported).Storing the command database in an ASCII-safe format.If you have the habit of opening and modifyingcommands.dbin a text editor,
it might be a good idea to store it with JSON by adding the following to your
configuration file:[tempcmds]db_format=jsonNote that this will very slightly degrade performance and increase the size,
however this should be a negligible amount for most purposes.Creating commandsOnce your bot has connected to IRC (or Discord), you can usetempcmdto
create (permanent) commands. You can either do.tempcmd <command> <type> <code>to add a tempcmd with a set type, or.tempcmd <command> <code>to auto-detect the type (as long as the first word
in<code>is not a valid type).For now, tempcmds.py has a list of code types/formats and what they do.To delete commands, you can usetempcmd del/delete/remove <command>. To create
a command calleddel,deleteorremove, you can prepend your bot's prefix
to the command name.Creating non-"tempcmd" commandsIf you want more fine-grained control over a command, you can add acustom_cmdsline to the[core]section of config.ini. The file specified
will be loaded and can define more powerful commands, for example:# A simple version command# The "requires_admin" parameter is optional and defaults to False.@register_command('version',requires_admin=False)defversion_command(irc,hostmask,is_admin,args):# irc: The miniirc.IRC (or miniirc_discord.Discord) object.# hostmask: The hostmask tuple, mostly from miniirc. Note that relayed#   messages (for example "<relayed_user> test") will have a hostmask#   similar to ('relayed_user@relay_bot', 'relay_bot_ident',#       'relay.bot.host/relayed/relayed_user').# is_admin: Either `False` or a string with the admin match (for example#   a hostmask or Discord tag.# args: ["#channel", "command parameters"]#   For PMs, "#channel" will be the sender (hostmask[0]).irc.msg(args[0],miniirc.version)You do not have to import anything to getregister_command.Ifcustom_cmdsis a directory, all.pyfiles in that directory will be
loaded. If you want your custom commands file/directory in lurklite's source
directory, you can name itcustom_cmds.py(or, for directories,custom_cmdsorcommands) to makegitignore it.Built-in commandslurklite has the following built-in commands:reboot: Reboot the bot.tempcmd: Create and delete commands.version: Display the miniirc version and quit.Migrating from very old versions of lurkliteOlder versions of lurklite (pre-v0.1.0) had atempcmds.dbcreated usingrepr(). This is slow(-ish) and inefficient, so is no longer supported. If you
still have a pre-v0.1.0tempcmds.db, you can runtempcmds_migrate.pyto update it to the new msgpack/JSON format.