latitudegames / AIDungeon

Infinite adventures await!
http://www.aidungeon.io/
MIT License
3.18k stars 556 forks source link

[FEAT] Discord Bot for playing AI Dungeon 2 together. #206

Open ethanspitz opened 4 years ago

ethanspitz commented 4 years ago

🚀 Feature Request

What problem is this feature looking to solve? As a group, you can play AIDungeon together in a Discord Channel

Describe the solution you'd like Ability to run AIDungeon as a Discord Bot

Describe alternatives you've considered I've already written a pexpect wrapper, though my code is terrible as I'm more of a C programmer than a Python programmer. See a diff here of my proposed Discord Bot. (I didn't want to make a pull request because I honestly don't think it's worthy of being merged in yet).

https://github.com/AIDungeon/AIDungeon/compare/develop...ethanspitz:develop

Additional context Right now the bot I wrote simply uses pexpect to wait for user input to be needed. When new messages come out after user input, it pipes it to the discord channel #ai-adventure (I should probably make that configurable). Right now, it takes anything after "!ai " and feeds that into AI Dungeon 2.

As I've personally had stability issues, I have it so it auto saves after every command, can detect crashes, auto recover, and print the save code to the room in order to allow anyone to reload the game where it crashed.

Ultimately, I'm curious if there are others interested in using this. I'm open to suggestions on how to best manage this.

RyushoYosei commented 4 years ago

okay that's a neat idea, I actually was wanting to do something like this with some friends online, though I was going to run the program and then copy and paste the responses the AI gave to them so they could decide what to do

thrik commented 4 years ago

I also really want this in my discord channel!

ghost commented 4 years ago

Hi! I just found this project, and this issue stood out to me since I do some work with discord.py. I'd be interested to help bring this project to a Discord bot.

My idea is: the main set up commands would be on their own (will describe in a minute), then when the game is set up, an user can call [p]start to get the bot to listen to every message in that channel (without needing to use a prefix) from allowed users. At any time, save / exit commands can be used by specifying the bot prefix.

Some commands I'm thinking of: (i'm not 100% familiar with all the possible input so this list can and will be expanded)

In-game commands:

Some moderation commands are also possible - for example, "locking" a channel so users who are not part of the game can only read but not send messages to it.

A couple more thoughts: I'd suggest using discord.py's wait_for to wait for user input, then send a message like "Processing... ⌛️" which will be then deleted after the response is ready. (or just using the "User is typing" function, although that might be a little less intuitive for users) As per your stability / reloading issues, there can be a background task which checks if the worker processes are running, and restarting them with the latest save files. I don't think it would be an issue to have a "temporary save" at each message?

Please let me know what y'all think, and what should be added / changed / not added / how practical this really is to run with multiple instances, since from what I understand this is heavily taxing on hardware resources

--berries

poperigby commented 4 years ago

It would also be cool to make the bot work on Matrix.

kittenswolf commented 4 years ago

I made a bot that allows you to play AI Dungeon with your friends. You can create a session and then add friends to it to play.

Usage: p!play - Start a new session p!add @user - Add a friend to play with p!start - Chose story mode

Invite: https://discordapp.com/oauth2/authorize?scope=bot&client_id=677143240356397067&permissions=387136

img img2

Invite: https://discordapp.com/oauth2/authorize?scope=bot&client_id=677143240356397067&permissions=387136

@ethanspitz @RyushoYosei @thrik @berries-boop

TheFiZi commented 4 years ago

@kittenswolf Do you have the source for your bot on Github somewhere? I've got a bug report and some feature requests.

kittenswolf commented 4 years ago

@TheFiZi While the code isn't public yet (I want to clean it up before releasing), you can submit issues/feature requests here: https://github.com/kittenswolf/aid-issues

PaulBellow commented 4 years ago

Is this still up?

ehamawy commented 4 years ago

It's down and the creator won't release the sauce :/

kittenswolf commented 4 years ago

Sorry for the delay. The source is now up:

https://github.com/kittenswolf/aid-bot

PaulBellow commented 4 years ago

Thanks, @kittenswolf. No worries. I'm pressed for time too, but I'll let you know if I tinker and get it working. I've got a decent small Discord community of gamers, so I'm definitely interested in it.

hverma4321 commented 4 years ago

The bot is offline