Hi all, I've spent the past few days working on a bot framework in Python. It is nowhere near complete: https://github.com/Transfusion/durararobot
I was inspired by bots like 小氷 and other interesting bots using CleverBot or other chatbot APIs. Unfortunately I have not seen any open source bots, and all efforts I've seen so far are based on JS, whether node.js or GreaseMonkey plugins. I chose Python because I think that much more complex things like moderating games (e.g. one use case is trivia games in multiple rooms at once; OOP, inheritance is easier) and managing lots of threads is not the easiest thing to do in JS, and there are some things which are easier to do with threads (e.g. converting YouTube videos to mp3, which is CPU heavy) than with asynchronous event loop.
The main idea here is to separate networking from the modules (one module per type of command; e.g. a module which responds to !time now
, another module which responds to !music add http://youtube.com/blahblahblah
. . In fact, the entire bot is designed so that you can load and unload modules on the fly without having to restart the bot. I didn't mention in the README on the GitHub page, but you can try unload_module TimeReporter
on the bot's CLI interface, and load_module TimeReporter
to test this out. The other benefit is that the bot can establish multiple connections, with the same name and tripcode to different rooms.
My vision is that anyone, even someone completely new to programming, can develop modules for the bot without having to worry about the networking or state or room joining or anything of the nasty things in the picture especially the left hand side which is troublesome. If you look in modules/modules.py
, ideally anyone new should just be able to implement
@abstractmethod
def handler(self, conn_name, message):
and receive the messages from the server in a nice object, and send using self.bot.send(conn=conn_name, msg=Some Message)
.
Also, it saves me the trouble of thinking about what features to develop, because I don't have a very good imagination, I don't know how to roleplay, and I don't play tabletop games. Regardless, some of the things that should be possible are:
Easy
Music DJing plugin like 小氷 from Chinese music sources like NetEase, Xiami, and QQ, along with YouTube. (in progress, I'm working on it now).
Bartender/Restaurant owner. Everyone seems to love cafes and bars; I should be able to !order cream cheese nachos
and the bot replies at 1 minute with "Heating the cheese," 2 minutes with "Grilling the nachos", ... etc. and gives you a nice neat picture of the finished food.
Mailbox/"voicemail" plugin; e.g. !tell nagisa i miss you
should well, say "transfusion said i miss you" to nagisa in DM when nagisa comes into one of the rooms.
Anti-spammer rules, e.g more than 3 messages per second is a kick, repeated offenses are a ban.
Remember images and other funny things posted in the room previously (maybe part of chatroom logging.)
Voting plugin that can vote for any command. E.g, maybe you can't decide whether to play Werewolf or some other game. !createvote !start werewolf or !start other game 2min
, and people can do !vote 1
or !vote 2
and at the end of 2 minutes the command with more votes is run (so voting for music, voting to kick someone, etc, should immediately work)
Cooldown, if someone is trying to spam the bot by issuing a command over and over again it ignores that particular person for a while.
Medium
Trivia game. Slightly harder because need to have a persistent database, I'm thinking Python's ZODB
. Trivia questions are everywhere, e.g. https://opentdb.com
Chat log database with searching functionality.
Web interface for the bot to let people invite the bot into their channel, manage logs, and maybe load and unload plugins selectively for that channel.
Meme maker with GIFs.
Next level
http://rabb.it plugin to setup and watch videos with other people in the channel in sync. Will be very hard because have to figure out how to broadcast a video stream.
Radio Plugin; think beatmatching music so you're just broadcasting one long stream of music into the channel... maybe overkill, lol...
This is a learning project for me too, I'm definitely not an expert by far, and I'm still trying to get things work rather than to make everything look elegant. If you know a bit of OOP, how threads work, and callbacks you're set, I want you on board. (There is a discord channel on the GitHub page if you want to chat with me)
BTW, 我会说中文,虽然不是我的母语。代码无国界!
Will you join me? Do you guys think this idea is worthwhile? Any ideas for modules?