Giter Club home page Giter Club logo

terracord's People

Contributors

ldilley avatar micaeljarniac avatar moisterrific avatar monoverde888 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

terracord's Issues

Refactor stuff

Reduce the file length of Terracord.cs by migrating some of the fields and methods to separate classes in other files. The current single class is becoming larger as functionality is being added. Refactoring will help thwart the looming unwieldiness. The new classes should still reside in the Terracord namespace.

For example, all of the XML configuration variables and GenerateConfigFile() can be moved to a Config class. The parsing can also be moved to a new method within this new class. A Config object can then be instantiated within the Terracord class and botClient can access the terracord.xml option values using the object after proper construction.

Log() and others (such as the method to calculate plugin uptime) can also be moved to another utility class to help with refactoring.

See https://refactoring.guru/move-field and https://refactoring.guru/move-method for guidance.

Handle potential exceptions

Feature Description

  • To increase plugin resilience, implement exception handling during the following operations:
  • Parsing terracord.xml
  • Writing to log files
  • Type conversion
  • Receiving/sending Discord messages (validate server connectivity)
  • Broadcasting messages to Terraria players

Log timestamp changes format unexpectedly

Expected Behavior

  • Log timestamp should be in the same format throughout the runtime of the program.

Actual Behavior/Symptoms

  • Log messages contain a timestamp of the form [1/2/2020 12:46:59 PM] and then it changes to [02/01/2020 12:46:59] with the initial REST message. See #14 for details.

How to Reproduce Behavior/Symptoms

  • Load Terracord.dll.

Terracord Version

  • 0.1.0

Terraria/TShock Version

  • 1.3.5.3/4.3.26

Discord.Net Version

  • 2.1.1

.NET/Mono Version

  • .NET Framework 4.8

Operating System

  • Windows 10 Home

Output/Screenshot(s)

[1/2/2020 12:46:43 PM] Server has started.
[1/2/2020 12:46:59 PM] Connecting to Discord...
[1/2/2020 12:46:59 PM] 12:46:59 Discord     Discord.Net v2.1.1 (API v6)
[02/01/2020 12:46:59] 12:46:59 Rest        GET voice/regions: 323.89 ms
[02/01/2020 12:46:59] 12:46:59 Rest        GET users/@me: 139.81 ms

Add various general commands

Allow the use of a bot command, <prefix>playerlist, from within Discord. The command's use and issuer should be relayed to the Terraria server. The command output should also be viewable from Discord and will show who and how many players are currently logged into the TShock server.

Add localization support

Feature Description

  • Add configurable locale in terracord.xml. The default should be en-US unless otherwise specified. Some examples would be de-DE, en-GB, es-MX, fr-CA, pt-BR, ru-RU, and zh-CN (among many others). This is also related to any string conversion findings per #38.

Bot not relaying messages in discord

Hi

I understand this probably isn't the best place to ask for help, but I have tried to get this working and not sure where I'm going wrong anymore (spent so much time trying to get this working! :D). I have built the terracord.dll and put all the bot info (bot token and channel ID) in to the xml config file. I can see terracord executing messages in the Terraria server console, however Discord doesn't seem to be communicating with Terraria (I have a bot but it is not executing any messages). I would really, really appreciate your help with this, thanks.

Add support for plugin reload

Feature Description

  • Allow the Terracord plugin to be reloaded from TShock. Most of the options in terracord.xml could be set dynamically without reconnecting to Discord. Only the bot token would require a reconnect. @moisterrific mentioned that there is a OnReload() hook we can leverage.

Ensure Terracord still reconnects after a disconnect

This issue is just a reminder to validate whether or not Terracord reconnects successfully to Discord after connectivity is lost. The BotConnect() method was modified recently so it does not block and this may impact reconnecting to the service. This issue can be closed once the functionality is confirmed as being successful. This is part of the checklist for #22.

Terraria commands should not get sent to Discord

Expected behavior

Slash (/) commands and any arguments should not get transmitted to Discord.

Actual behavior/symptoms

Slash commands get relayed to Discord.

Steps to reproduce behavior/symptoms

Issue an in-game command.

Terracord version

0.1.0

Terraria/TShock version

1.3.5.3/4.3.26

.NET/Mono version

N/A

Operating system

N/A

Add administrative TShock commands

Feature Description

  • Allow the bot owner and perhaps a configurable Discord role remote access to administrative TShock commands such as ban, kick, kill, mute, reload, restart, save, stop, tp, etc.

Convert received Discord mentions

Feature Description

  • Channel mentions appear as <#1234567890> and user mentions appear as <@!1234567890> when messages from Discord containing them are broadcasted to TShock players. These should be converted to friendly names such as #channel and Joe prior to being broadcasted to TShock players. This will require scanning every received message for the mention patterns and replacing any instances in the message.

1.1.0 release checklist

  • Categorize and close any remaining issues associated with this release
  • Set plugin version to 1.1.0 in Terracord.cs and Terracord.csproj
  • Any bug fixes will increment the patch level beyond 1.1.0 at this point (1.1.1 for example)
  • Create 1.1.0 tag (and any further tags to accommodate bug fix releases)
  • Create and publish release zip archive containing a readme.txt with installation instructions, a default terracord.xml configuration file, and all necessary DLLs (including localization resources) accompanied by any relevant 3rd-party licenses

Add configurable Terraria message color

Feature Description

Allow messages relayed from Discord to have a configurable color when displayed within Terraria. The TShock Broadcast(string msg, byte red, byte green, byte blue) method supports this functionality. The RGB values can be set in the configuration file after #1 is implemented.

Set Discord text channel topic to offline on shutdown

Feature Description

  • In Dispose(), set the Discord text channel topic to Relay offline (including any translations) to indicate that the relay is currently not available. In the interim, the Discord bot being offline is a pretty good indicator that the topic will not be getting updated. ;)

Add debug mode

Feature Description

  • Add debug mode for increased log verbosity. This can help during troubleshooting.

1.2.0 release checklist

  • Categorize and close any remaining issues associated with this release
  • Set plugin version to 1.2.0 in Terracord.cs and Terracord.csproj
  • Add support for Terraria 1.4.x/TShock 4.4.x (#70)
  • Create 1.2.0 tag
  • Create and publish release zip archive containing a readme.txt with installation instructions, a default terracord.xml configuration file, and all necessary DLLs (including localization resources) accompanied by any relevant 3rd-party licenses

Add some unit tests

Feature Description

  • Leverage xUnit or NUnit for some unit tests. appveyor.yml and .travis.yml will need to be updated to run the tests on each respective platform.

Add help command

Add a Discord help command which provides a summary for each command along with its usage (arguments).

Do not relay msg to Discord from muted players.

Feature Description

  • If possible, do not relay messages back to Discord channel from players who are muted in-game.

Notes: TShock will prevent messages from muted players being shown in the in-game chat. And has a bool flag TSPlayer.mute. However, TShock by default cannot track player mutes to its database so a player can simply rejoin to remove the mute. This can be solved by the use of plugins, though.

Add log severity and console color based on severity

Add a 2nd parameter to Util.Log() for severity. Use a switch statement to modify Console.ForegroundColor based on the passed severity level (ConsoleColor.Red for exceptions, errors, and critical messages, ConsoleColor.Yellow for warnings, ConsoleColor.White for informational messages, and ConsoleColor.DarkGray for trace, debug, and verbose messages).

Add configurable message limit

Feature Description

  • Limit the size of messages sent from Discord to Terraria. This limit can help restrict message flooding/scrolling within the game. This should be configurable in terracord.xml with a default value of 512. Any excess characters should be truncated.

Create config file and ability to parse options

Create a configuration file in JSON (terracord.json) or YAML (terracord.yaml) format which stores the Discord bot token and bot prefix. The options should be read during plugin initialization.

Update README.md to include localization instructions

Since PR #42 added localization support for Arabic, Chinese (Simplified), Dutch, English, French, German, Italian, Japanese, Korean, Polish, Portuguese, Russian, and Spanish, README.md should be updated to inform users how to set their locale in terracord.xml. The various language folders containing Terracord.resources.dll should reside in the top-level directory with TerrariaServer.exe. Setting the locale in terracord.xml to es-MX, for example, would fall back to es (generic Spanish). If a locale is unsupported, the default language is English.

Convert received Discord emojis

Feature Description

  • Custom emojis appear as <:emoji_name:1234567890> when messages from Discord containing them are broadcasted to TShock players. These should be converted to simply :emoji_name:. Other standard emojis appear as ** within the game, �� on the TShock console, and get rendered as proper Unicode characters in terracord.log. How to best handle this still needs to be determined.

Handle Terraria -> Discord messages

Leverage TShock hooks from the API to relay Terraria messages to a Discord server. The messages should use similar formatting and emojis as DiscordSRV. For example, server startup/shutdown messages should appear as bold in a Discord text channel. They should also be prepended with an appropriate emoji such as :octagonal_sign: for a server stop message. Player messages should appear as: "<player_name> some message". We are using Discord.Net for Discord connectivity.

Put Terracord config and log file into a folder

Put terracord.xml and terracord.txt into a tshock\Terracord folder

not a big deal but it would help better organize things for servers that have a lot of plugin configs/logs/database files, etc.

at least according to one of the lead TShock devs
image

1.0.0 release checklist

  • Ensure Terracord still reconnects to Discord after a disconnect without Task.Delay(-1) in BotConnect() (related to #25)
  • Categorize and close any remaining issues associated with this release
  • Set plugin version to 1.0.0 in Terracord.cs and Terracord.csproj
  • Update copyright year as a range to include 2020 in Terracord.cs and Terracord.csproj
  • Create 1.0.0 tag
  • Create and publish release zip archive containing a readme.txt with installation instructions, a default terracord.xml configuration file, and all necessary DLLs accompanied by any relevant 3rd-party licenses

OnLeave(LeaveEventArgs args) throws exception due to null reference

Expected Behavior

  • No exception thrown

Actual Behavior/Symptoms

  • See output below.
[Server API] Warning Plugin "Terracord" has had an unhandled exception thrown by one of its ServerLeave handlers:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Terracord.Terracord.OnLeave(LeaveEventArgs args)
   at TerrariaApi.Server.HandlerCollection`1.Invoke(ArgsType args)

How to Reproduce Behavior/Symptoms

  • Leave the TShock server as a player.

Terracord Version

  • 0.1.0

Terraria/TShock Version

  • 1.3.5.3/4.3.26

.NET/Mono Version

  • Any

Operating System

  • Any

Allow message suppression for incomplete connections

Feature Description

  • In Terracord.cs, uncomment the exception handling in the PlayerEventNotify() method and wrap the Util.Log() call in the catch() block with an if check for the debug mode toggle. If debug mode is disabled, we can suppress these incomplete connection messages when the object is null.

Netstandart Error

Expected Behavior

  • Plugin Works.

Actual Behavior/Symptoms

  • Netstandart not found.

How to Reproduce Behavior/Symptoms

  • Just start the server with plugins.

Terracord Version

  • 1.1.0

Terraria/TShock Version

  • 1.3.0.7 / 2.1 (PE)[TShock Zombie]

Discord.Net Version

  • Check from Terracord Release 1.1.0

.NET/Mono Version

Operating System

  • Windows Server 2012 R2

Output/Screenshot(s)

  • None

Additional Notes

  • There is no space that .NET SDK can be installable on our Server(Drains too much RAM and Disk that not allows our servers run).

Easier Discord user mention

Not sure how feasible this would be, but it would be nicer if you didn’t have to type out the full Discord tag to mention a user.

For example: if the user I want to mention is John, it will match if I type only “Jo”

If there are users named John and Joseph, typing “Jo” will return an error message telling the command user to be more specific.

I just know TShock has this feature for most commands where you can just type a part of a full name and it will match it.

In-game @ relay breaks if server has users with || in name

Expected Behavior

  • mention users from in-game "just works"

Actual Behavior/Symptoms

  • could not mention ANY users if the server contains users that have || in their username, and if you just do a @ without any name, it will end up mentioning that user with the || a bunch of times. However, after I kicked those two users from my server it works as intended.

How to Reproduce Behavior/Symptoms

  • try mentioning anyone if your server contains users with || in their username, not nickname

Terracord Version

  • 1.0.0

Terraria/TShock Version

  • 4.3.26 mobile (though it shouldn't make much of a diff since the code is pretty much identical)

Discord.Net Version

  • dunno

.NET/Mono Version

  • dunno

Operating System

  • Windows 10

Output/Screenshot(s)

image

image
terracord.log

Unhandled Instances

Instance A

Server enforcing mediumcore or higher characters:

  • if a softcore player attempts to join, TShock will "kick" that player
  • however, a relay msg is still sent to Discord that looks like this: "has left the server."

Instance B

Banned player attempting to connect:

  • if a banned player attempts to join, TShock will "disconnect" that player
  • however, a relay msg is still sent to Discord that looks like this: "player name has joined the server."
  • it will not show "player name has left the server." when it boots the banned player

Ideally

  • no message is relayed to Discord at all for both instances.

Terracord Pings Random User

Expected Behavior

  • I don't know

Actual Behavior/Symptoms

  • Pings random user.

How to Reproduce Behavior/Symptoms

  • Ping someone in Terraria Server

Terracord Version

  • 1.1.0

Terraria/TShock Version

  • 1.3.0.7 / 2.1 (PE)[TShock Zombie]

Discord.Net Version

  • Check from Terracord Release 1.1.0

.NET/Mono Version

  • .NET: 4.0
  • Mono: 6.8.0.105

Operating System

  • Windows Server 2012 R2

Output/Screenshot(s)

image

Could this be updated for 1.4 please?

I didn't expect it to work but tried to load the available version and it didn't like the discord file on bootup. Is there plans to update this for 1.4 as its very useful.

How to handle image relays in-game?

If a Discord user send an image in the relay channel, it will show up in-game as a blank message. Is this intended?

(though a quick workaround is to simply disable image permissions in that channel)

Add "..." typing status prior to command response

Feature Description

  • Add "..." typing status for the Discord bot user prior to it responding to commands. This would add some realism. Do not do this for regular chat since the frequency of regular chat messages would likely be significantly greater than command requests in practical use cases.

Add option to disable chat and/or broadcasts

Some server maintainers may want to cut down on the chatter or only see broadcast information. Add the following pair of options to terracord.xml:

<!-- Toggle broadcasts displayed in Discord -->
<silence broadcasts="false" />

<!-- Toggle game chat displayed in Discord -->
<silence chat="false" />

Add logging

Log Terracord informational messages, warnings, and errors to a file.

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.