Code Monkey home page Code Monkey logo

faf-qai's Introduction

Continuous integration

Faforever.Qai

The rewrite and combining of Dostya/Qai into a single application.

QAI

This is a total rewrite of QAI

Dostya

This is a total rewrite of Dostya

Installation

Just dump the release in a folder and run the "Qai.exe" executable.

Configuration

To Create a new Database file for testing use Update-Database --project Faforever.Qai.Core in the Packet Manager Console. If you are using the .NET Core CLI, run dotnet ef database update --project src/Faforever.Qai.Core from the Faforever.Qai solution folder.

Once you have a test.db file, move it into the Faforever.Qai project if it is not there already, and make sure to set property Copy to Output Directory to Copy if newer. You can use Copy Always, but data will be reset between tests.

See this reference for installing the EF Core tools for the .NET Core CLI

Commands

In order to invoke a command you just type it in #aeolus in either the client or discord or you can send a private message to the bot. You prefix all commands with an '!'. For an example in order to invoke the player command you do. !player coolmcgrrr

See Issue #9 for a full list of commands.

faf-qai's People

Contributors

brutus5000 avatar chrsin avatar crotalus avatar dependabot[bot] avatar soyvolon avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

crotalus

faf-qai's Issues

Create pipelines

We need the following pipelines:

Create release (Should create a new release of the client)
Continuous Integration. (Should be run on every push and verify the state of the code)

Create dockerfile

We need a dockerfile for creating the image that should be run on the server.

An exception occurred while executing player

Faforever.Qai.Core.QCommandsHandler[0]
      Failed to execute command:
      An exception occurred while executing player.
      System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
         at System.Text.Json.JsonElement.GetProperty(String propertyName)
         at Faforever.Qai.Core.Operations.Player.ApiFetchPlayerStatsOperation.FetchPlayer(String username) in /build/src/Faforever.Qai.Core/Operations/Player/ApiFetchPlayerStatsOperation.cs:line 28
         at Faforever.Qai.Core.Commands.Dual.Player.PlayerCommands.GetRatingsAsync(String username) in /build/src/Faforever.Qai.Core/Commands/Dual/Player/PlayerCommands.cs:line 32
         at Qmmands.Utilities.<>c__DisplayClass18_0.<<CreateModuleBaseCommandCallback>b__0>d.MoveNext()
      --- End of stack trace from previous location ---
         at Qmmands.Utilities.<>c__DisplayClass18_0.<<CreateModuleBaseCommandCallback>b__0>d.MoveNext()
      --- End of stack trace from previous location ---
         at Qmmands.CommandService.InternalExecuteCallbackAsync(CommandContext context)

Build Commands

Feature

✅ - Completed
❗ - Todo
✘ - Abandoned
⁉️ - Needs further work

Mixed Commands

Status Command Permissions Description
alive/respond ALL Sends a response message to the user. Differs depending on the command context.
help ALL Sends help information
unit <unit ID> ALL returns unit information
map <map ID> ALL returns map information
wiki <terms> ALL searches the wiki
pool/ladderpool/ladder ALL shows the current 1v1 ladder pool
replay <replay ID> ALL returns the replay information
lastreplay <playername> ALL returns the last replay for the player
clan <clan tag/clan name> ALL returns clan information
searchplayer <playername> ALL returns list of players with similar names
player/ratings <playername> ALL returns detailed player information about a user
roll ALL Rolls a dice.
eightball/8ball ALL Ask the mysterious 8ball a question.
taunt [person] ADMIN Taunts a person. Defaults to taunting yourself.
explode [person] ADMIN Explodes a person. Defaults to yourself.
hug <person> ADMIN Hugs a person
flip ADMIN (╯°□°)╯︵ ┻━┻
gullible ALL Displays additional commands. (Taunt the user who runs this command.)
link <website> [WORDS] ALL Links to a website - What is this one supposed to do again?
remind <User> <TimeSpan> <message> ALL Reminds a person at a designated time from now.
puppet <user> <message> ADMIN Makes another person send a message.
slap <user> ADMIN Slaps a user.
streams ALL Lists all current streams
casts ALL Lists the mosts recent casts
badwords <get | add <word> <gravity> | del <word>> ADMIN Manages badwords.
rwords ALL Prints the list of checked reactionwords
reactionwords <get | add <word> <reply> | del <word>> ADMIN | MANAGE_MESSAGES Manages reactionwords. {sender} in the <reply> will be replaced with the person who triggered the reaction.
repeat <get | add <ID> <seconds> <channel> <message> | del <ID>> ADMIN | MANAGE_MESSAGES Makes QAI repeat words in a channel each <seconds>.
google [words] ALL Googles something.
tournaments/tourneys ALL Gets the current tournaments.

IRC Only Commands

Status Command Permissions Description
join <IRC Channel> ADMIN Forces the bot to join another channel.
leave [IRC channel] ADMIN Forces the bot to leave the channel, or a provided channel
offlinemessage <User> <message> ALL - HIDDEN Sends a message to a user once they come online.
puppet <user> <message> ADMIN Makes another person send a message.
groupping <group name> ALL Pings all people in the indicated group
group <get | join <group name> | leave <group name>> ALL Gets group list, or joins/leaves a selected group.
groupmanage <get | add <group name> [TEXT] | del <group name> | join <group name> <player name> | leave <group name> <player name>> ADMIN Manages groups.
blacklist <IRC user> ADMIN Prevents a user for using streams or casts
badwords <get | add <word> <gravity> | del <word>> ADMIN Manages badwords.
move <nick> <channel> CHATLIST Moves a user into a channel.
chatlist [<channel> | add <channel> <user> | del <channel> <user>] CHATLIST Manages chat lists?
addfirend <username> ALL Adds a friend. You get notifications when they come online.

Discord Only Commands

Status Command Permissions Description
link <playername> ALL Links a FAF account to a Discord account.
subscribe <rolename> ALL Subscribes to a Discord role set by the bot
unsubscribe <rolename> ALL Unsubscribes from a Discord role set by the bot
registerrelay <Discord Channel> <IRC Channel> MANAGE_CHANNELS Registers a Discord channel to relay with IRC
removerelay <IRC channel | Discord channel> MANAGE_CHANNELS Removes a registered Relay
blacklist <Discord User> MANAGE_MEMBERS Prevents a user from using commands on this guild
blacklist MANAGE_MEMBERS Gets the current list of blacklisted users
unblacklist <Discord User> MANAGE_MEMBERS Removes a user from the blacklist
restrict <command name> MANAGE_GUILD Prevents anyone but those with moderation permission for using a command.
unrestrict <command name> MANAGE_GUILD Removes a restriction on a command.
fixbridge MANAGE_CHANNELS Reinitialize IRC relays
links/showlinks <Discord Member> MANAGE_MEMBERS Shows current user to IRC account link for a member.
unlink <user ID | FAF Id> MANAGE_MEMBERS Force un-link a user.
loghere MANAGE_GUILD Registers the current channel for moderation action logging.
testlog MANAGE_GUILD Tests the log channel.
record <command name> <message> MANAGE_GUILD Records a predefined message that will show up next time anyone fires the command. Does not stop command execution.
record <command name> MANAGE_GUILD Removes a record associated with a command.
records/showrecords MANAGE_GUILD Shows the recorded messages
ban <Discord User> [duration] [message] BAN_MEMBERS Bans a user from the server with an optional message and ban time.
kick <Discord User> [message] KICK_MEMBERS Kicks a user from the server with an optional message.
warn <Discord User> [message] MANAGE_MESSAGES Warns a user with an optional message.
userinfo <Discord User> MANAGE_MESSAGES Gets the bans/kicks/warnings for a user.
registerrole <Role> MANAGE_ROLES Registers a new role with the bot.
unregisterrole <Role> MANAGE_ROLES Removes a role registered with the bot.
logmapshere MANAGE_CHANNELS Adds the channel to the map watching list- new maps will automatically be show in this channel whenever they are uploaded
unlogmapshere MANAGE_CHANNELS Removes the channel from the map watching list.

Setup Webhooks to send IRC data to.

Feature

Use Discord Webhooks to receive IRC messages to prevent an influx of requests going through the Discord API.

Discord Command

The Discord command will be used to create or re-assign an existing webhook to a channel, and store what IRC channel it is linked to in the application.

Internal

Store the webhooks in such a way they can be accessed easily from either the IRC client or the Discord client. This would require access from either a string for an IRC channel name or a ulong value from a Discord channel ID.

Webhook body needs an implementation that allows easy access for filling the JSON body of the request.

Webhook service should be used to apply any changes, so existing webhooks are not continuously filtered through for the values needed.*

*There may be a better way of doing this

Requirements

  1. Discord command to link a Discord Channel to an IRC channel
    1a. Moves an existing webhook if one exists for that IRC channel
    1b. Creates a new webhook if one is needed.
  2. Discord Messages must relay.
    2a. Any message sent in a linked Discord channel is sent to the IRC client
    2b. Any message sent in a linked Discord channel is sent to other Discord channels that are subscribed to the same IRC channel.
  3. Any message sent in an IRC channel that is linked to will be sent to the proper Discord channels.

Prototype IRC Implementation

We don't know enough about IRC so we need a protoype to get our feet wet.

Covers

  • Handling commands
  • Prototype for link IRC to Discord (relay)

Long running commands cause Discord MESSAGE_CREATED event timeouts

info: System.Net.Http.HttpClient.ApiClient.ClientHandler[100]
      Sending HTTP request GET https://api.faforever.com/data/game?include=mapVersion,playerStats,mapVersion.map,playerStats.player,featuredMod,playerStats.player.globalRating,playerStats.player.ladder1v1Rating,playerStats.player.clanMembership.clan&filter=playerStats.player.login==Soyvolon
[2021-01-20 18:01:50 -05:00] [104 /EventHandler] [Error] Event handler exception for event MESSAGE_CREATED thrown from System.Threading.Tasks.Task QMmands_MessageCreated(DSharpPlus.DiscordClient, DSharpPlus.EventArgs.MessageCreateEventArgs) (defined in Faforever.Qai.Discord.DiscordBot)
Emzi0767.Utilities.AsyncEventTimeoutException`2[DSharpPlus.DiscordClient,DSharpPlus.EventArgs.MessageCreateEventArgs]: An event handler caused the invocation of an asynchronous event to time out.
[2021-01-20 18:01:50 -05:00] [104 /EventHandler] [Error] Event handler exception for event MESSAGE_CREATED thrown from System.Threading.Tasks.Task Client_MessageCreated(DSharpPlus.DiscordClient, DSharpPlus.EventArgs.MessageCreateEventArgs) (defined in DSharpPlus.DiscordShardedClient)
Emzi0767.Utilities.AsyncEventTimeoutException`2[DSharpPlus.DiscordClient,DSharpPlus.EventArgs.MessageCreateEventArgs]: An event handler caused the invocation of an asynchronous event to time out.

Command still executes properly, but the command handler errors.

This is caused by long running command pausing the event handlers, when the commands should be running elsewhere. Code needs to be refactored for the Discord MESSAGE_CREATED event handling

Setup Entity Framework for SQLite

Feature

Setup EF Core with SQLite for storing data over application sessions.

Data to be stored:

Discord Guild specific data

  • Guild ID [Key]
  • User blacklists
  • FAF Account links
  • Command Records

Relay data

  • Discord Guild ID [Key]
  • Discord channels linked to an IRC channel
  • Webhook strings for linked channels.

Add Release framework

Release should be done in a way so QAI can run from a Docker container on a specific release server (Ubuntu?).

Attribute Based Permission Checks

Feature

Create a system for Attribute based permission verification for commands. See DSharPlus.CommandsNext permission attributes for examples.

Allow for a mix of DSharPlus.Permissions emun along with other permissions that are used with the IRC client.

Write Code Comments

Write Code Comments

Fill in the existing programing with more code comments about what the code does.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.