I tried to create my own "info" bot with command /info based of some other plugins (ServerChat/SaveAnnouncer).
To try and learn more and have a greater feeling of ownership maybe.
It should grab a couple of definitions from the config file but at the moment it is not doing so. Or, partially it is.
It grabs the message color. Which is all. It does not print the ChatIcon nor Title.
It creates and verifies the config - but seems to only grab some of the info (color/size).
I was hoping somebody could point me in the right direction? Since its not giving any errors and is in some way working - I dont know what to look for.
It sends the reply, and with color formatting (i added partially white color to verify its getting color).
https://i.imgur.com/o7uxIK4.jpg
using System;
using Newtonsoft.Json;
using System.Collections.Generic;
using Oxide.Core;
using System.Linq;
using System.Text;
using Oxide.Core.Libraries.Covalence;
using Oxide.Core.Plugins;
namespace Oxide.Plugins
{
[Info("Infobot", "JE", "1.0.3")]
[Description("Serves as Tier 0 self service information bot.")]
public class Infobot : RustPlugin
{
#region Config
Configuration config;
class Configuration
{
[JsonProperty(PropertyName = "Icon (SteamID64)")]
public ulong ChatIcon = 0;
[JsonProperty(PropertyName = "Title")]
public string Title = "Title";
[JsonProperty(PropertyName = "Title Color")]
public string TitleColor = "#deff00";
[JsonProperty(PropertyName = "Title Size")]
public int TitleSize = 15;
[JsonProperty(PropertyName = "Message Color")]
public string MessageColor = "#dfdfdf";
[JsonProperty(PropertyName = "Message Size")]
public int MessageSize = 15;
}
protected override void LoadConfig()
{
base.LoadConfig();
try
{
config = Config.ReadObject<Configuration>();
if (config == null) throw new Exception();
}
catch
{
Config.WriteObject(config, false, $"{Interface.Oxide.ConfigDirectory}/{Name}.jsonError");
PrintError("The configuration file contains an error and has been replaced with a default config.\n" +
"The error configuration file was saved in the .jsonError extension");
LoadDefaultConfig();
}
SaveConfig();
}
protected override void LoadDefaultConfig() => config = new Configuration();
protected override void SaveConfig() => Config.WriteObject(config);
#endregion
[ChatCommand("info")]
private object HelloCommand(BasePlayer player, string command)
{
string icon = $"{config.ChatIcon}";
string title = $"<color={config.TitleColor}><size={config.TitleSize}>{config.Title}</size></color>\r\n";
string msg = $"<color={config.MessageColor}><size={config.MessageSize}>This is a <color=#ffffff>test</size></color>";
SendReply(player, msg, title, icon);
return true;
}
}
}