fragland / terracord Goto Github PK
View Code? Open in Web Editor NEW:evergreen_tree: A Discord <-> Terraria bridge plugin for TShock
License: GNU General Public License v3.0
:evergreen_tree: A Discord <-> Terraria bridge plugin for TShock
License: GNU General Public License v3.0
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.
terracord.xml
[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.[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
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.
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.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.
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.Log()
method to be configurable.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.
Slash (/) commands and any arguments should not get transmitted to Discord.
Slash commands get relayed to Discord.
Issue an in-game command.
0.1.0
1.3.5.3/4.3.26
N/A
N/A
ban
, kick
, kill
, mute
, reload
, restart
, save
, stop
, tp
, etc.<#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
in Terracord.cs
and Terracord.csproj
1.1.0
at this point (1.1.1
for example)1.1.0
tag (and any further tags to accommodate bug fix releases)readme.txt
with installation instructions, a default terracord.xml
configuration file, and all necessary DLLs (including localization resources) accompanied by any relevant 3rd-party licensesAllow 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.
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. ;)1.2.0
in Terracord.cs
and Terracord.csproj
1.2.0
tagreadme.txt
with installation instructions, a default terracord.xml
configuration file, and all necessary DLLs (including localization resources) accompanied by any relevant 3rd-party licensesAdd a Discord help
command which provides a summary for each command along with its usage (arguments).
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 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).
terracord.xml
with a default value of 512
. Any excess characters should be truncated.Periodically update the Discord bot's text channel topic to include:
Resolve all issues detected by the FxCop/Roslyn code analyzers. After installing the FxCop analyzer add-ons in Visual Studio, resultant recommendations should appear in the error list section as warnings.
AppVeyor is attempting to run unit tests while building Terracord. This is resulting in a build failure on AppVeyor (for example: https://ci.appveyor.com/project/ldilley/terracord/builds/31788530). I believe this is caused by the build
section in appveyor.yml
which will build all projects in a solution by default. I am uncertain why this has not occurred in previous builds.
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.
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.
<: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.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.
It'd be nice if you could make it so we could tag people using Discord from Terraria using the @ command. :)
Add step in README.md
installation section to copy terracord.xml
into tshock/
directory.
terracord.xml
is not found, generate a default config file. This can be done after #10 is implemented for FileNotFoundException
.Task.Delay(-1)
in BotConnect()
(related to #25)1.0.0
in Terracord.cs
and Terracord.csproj
Terracord.cs
and Terracord.csproj
1.0.0
tagreadme.txt
with installation instructions, a default terracord.xml
configuration file, and all necessary DLLs accompanied by any relevant 3rd-party licenses[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)
Messages from Discord users should appear as: "<username@Discord> some message". We are using Discord.Net for Discord connectivity.
Allow the ability to customize the sender prefix for Discord messages. Add the following to terracord.xml
:
<!-- Discord message sender prefix -->
<discord prefix="<user@Discord>" />
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.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 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.Server enforcing mediumcore or higher characters:
Banned player attempting to connect:
player name
has joined the server."player name
has left the server." when it boots the banned playerI 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.
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)
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" />
Log Terracord informational messages, warnings, and errors to a file.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.