{"id":28559077,"url":"https://github.com/toastdriven/toastbot","last_synced_at":"2025-06-17T10:35:07.565Z","repository":{"id":57476045,"uuid":"1581039","full_name":"toastdriven/toastbot","owner":"toastdriven","description":"A clean, extensible IRC bot using Python \u0026 gevent.","archived":false,"fork":false,"pushed_at":"2012-04-25T03:36:44.000Z","size":565,"stargazers_count":30,"open_issues_count":0,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-07T16:54:58.142Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/toastdriven.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-04-07T07:06:56.000Z","updated_at":"2024-01-03T14:09:49.000Z","dependencies_parsed_at":"2022-09-07T13:51:49.093Z","dependency_job_id":null,"html_url":"https://github.com/toastdriven/toastbot","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toastdriven%2Ftoastbot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toastdriven%2Ftoastbot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toastdriven%2Ftoastbot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toastdriven%2Ftoastbot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toastdriven","download_url":"https://codeload.github.com/toastdriven/toastbot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toastdriven%2Ftoastbot/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259039600,"owners_count":22796870,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-10T08:36:02.267Z","updated_at":"2025-06-10T08:36:07.775Z","avatar_url":"https://github.com/toastdriven.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Toastbot\n========\n\nA clean, extensible IRC bot using Python, irckit, gevent \u0026 requests.\n\n**Author:** Daniel Lindsley\u003cbr\u003e\n**License:** BSD\u003cbr\u003e\n**Version:** 0.4.2\n\n\nRequirements\n------------\n\n* Python 2.6+\n* gevent\n* irckit\n* requests\n\n\nUsage\n-----\n\nCreate your own ``bot.py`` file \u0026 drop in:\n\n    import toastbot\n\n    bot = toastbot.ToastBot('myircbot', '#myircchannel')\n    bot.setup()\n\nThen run it with ``python bot.py``.\n\n\nConfiguration\n-------------\n\nThe ``Toastbot`` object requires ``nick`` \u0026 ``channel`` arguments \u0026 can take a\nvariety of non-required options.\n\n### Required arguments\n\n* ``nick`` - The nickname of the bot, as a string.\n* ``channel`` - The channel the bot should connect to, as a string.\n\n### Options\n\n* ``server`` - The server the bot should connect to (default: ``irc.freenode.net``).\n* ``username`` -The username the bot should identify as (default: ``nick``);\n* ``realname`` - The human readable name the bot should provide (default: 'ToastBot').\n* ``debug`` - Controls if the IRC connection should dump debug messages (default: ``false``).\n* ``log_dir`` - Controls what directory the logs should go in (default: ``$INSTALL_DIRECTORY/logs``).\n* ``variants`` - Used to override ways to address the bot. Should be strings (default: ``[self.nick+': ', self.nick+', ', self.nick+'- ', self.nick+' - ']``).\n\n\nAvailable \"handlers\"\n--------------------\n\nHandlers are how the bot can perform actions based on an incoming message. They\nare simple methods hanging off the bot object. The built-in list consists of:\n\n* ``help`` - Provides a description of what I respond to.\n* ``dance`` - Get down and funky.\n* ``woodies`` - Best quote on the internet..\n* ``wiki`` - Search Wikipedia for a topic.\n* ``metar`` - Fetch a NOAA METAR by station code.\n* ``twitter`` - Search Twitter for a topic.\n* ``fatpita`` - Get a random fatpita image. For the lulz.\n* ``corgibomb`` - CORGI BOMB\n\n\nExtending the bot\n-----------------\n\nAdding on further handlers is relatively simple. At its most basic, it's simply\nadding on a new method decorated with ``toastbot.handler``. For example, logging\nhow many times a user has said something in the channel might look like:\n\n    import toastbot\n\n    class MyBot(toastbot.ToastBot):\n        talkers = {}\n\n        def __init__(self, *args, **kwargs):\n            super(MyBot, self).__init__(*args, **kwargs)\n            self.enabled_commands += [\n                self.how_chatty,\n            ]\n\n        def how_chatty(self, nick, text):\n            \"\"\"Logs how often a user has said something.\"\"\"\n            if nick in self.talkers:\n                self.talkers[nick] += 1\n            else:\n                self.talkers[nick] = 1\n\n            print self.talkers.items()\n\n\n    bot = MyBot('myircbot', '#myircchannel')\n    bot.setup()\n\nNote that this command does not require addressing the bot at all. If you want\na command that the bot responds to, you might write something like:\n\n    import toastbot\n\n    class StoolPigeon(toastbot.ToastBot):\n        # Assume the previous example, but adding...\n        def __init__(self, *args, **kwargs):\n            super(StoolPigeon, self).__init__(*args, **kwargs)\n            self.enabled_commands += [\n                self.stool_pigeon,\n            ]\n\n        def stool_pigeon(self, nick, text):\n            \"\"\"Rat out the talkers.\"\"\"\n            text = self.is_direct_command('stool_pigeon', text)\n\n            if not text:\n                raise NotHandled()\n\n            return str(self.talkers)\n\n    bot = StoolPigeon('myircbot', '#myircchannel')\n    bot.setup()\n\nThis checks to see if the bot is being directly addressed then returns a\nstring-ified version of the ``talker`` stats. The included handlers demonstrate\neven more complex behavior, such as how to do network fetches or asynchronous\nresponses.\n\nTo disable handlers:\n\n    import toastbot\n\n    class MyBot(toastbot.ToastBot):\n        talkers = {}\n\n        def __init__(self, *args, **kwargs):\n            super(MyBot, self).__init__(*args, **kwargs)\n            self.enabled_commands = [func for func in self.enabled_commands if func.__name__ != 'twitter']\n\n    bot = MyBot('myircbot', '#myircchannel')\n    bot.setup()\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoastdriven%2Ftoastbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoastdriven%2Ftoastbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoastdriven%2Ftoastbot/lists"}