Example #1
0
 public void takeAction(Client client, string section, bool alreadyBlocked = false)
 {
     if (!alreadyBlocked)
     {
         if (!String.IsNullOrWhiteSpace(cfg[section]["msg"]))
         {
             try {
                 Message(client, parseMSG(cfg[section]["msg"], client));
             } catch (Exception ex) {
                 PluginLog(Log.Level.Warning, $"Could not message {client.NickName}:\n{ex.Message}");
             }
         }
         if (!String.IsNullOrWhiteSpace(cfg[section]["poke"]))
         {
             try {
                 Poke(client, parseMSG(cfg[section]["poke"], client));
             } catch (Exception ex) {
                 PluginLog(Log.Level.Warning, $"Could not poke {client.NickName}:\n{ex.Message}");
             }
         }
     }
     if (cfg[section]["kickonly"] == "true")
     {
         //bot.QueryConnection.KickClientFromServer(client.Id, (parseMSG(cfg[section]["reason"]);
         try {                 // clientkick reasonid=5 reasonmsg=test clid=1
             var cmd = new Ts3Command("clientkick", new List <ICommandPart>()
             {
                 new CommandParameter("clid", client.Id),
                 new CommandParameter("reasonid", 5)
             });
             if (!alreadyBlocked && parseMSG(cfg[section]["reason"], client).Length < 100)
             {
                 cmd.AppendParameter(new CommandParameter("reasonmsg", parseMSG(cfg[section]["reason"], client)));
             }
             lib.SendCommand <ResponseVoid>(cmd);
         } catch (Exception ex) {
             PluginLog(Log.Level.Warning, $"Could not kick {client.NickName}:\n{ex.Message}");
         }
     }
     else
     {
         try {                 // banclient clid=1 time=0 banreason=text
             var cmd = new Ts3Command("banclient", new List <ICommandPart>()
             {
                 new CommandParameter("clid", client.Id),
                 new CommandParameter("time", parseMSG(cfg[section]["bantime"], client))
             });
             if (!alreadyBlocked && parseMSG(cfg[section]["reason"], client).Length < 100)
             {
                 cmd.AppendParameter(new CommandParameter("banreason", parseMSG(cfg[section]["reason"], client)));
             }
             lib.SendCommand <ResponseVoid>(cmd);
         } catch (Exception ex) {
             PluginLog(Log.Level.Warning, $"Could not ban {client.NickName}:\n{ex.Message}");
         }
     }
 }
        public string ListChannels()
        {
            if (!client.Connected)
            {
                return("Not connected!");
            }

            context.BufferOn();
            List <ResponseDictionary> Channels = client.SendCommand <ResponseDictionary>(new Ts3Command("channellist")).ToList();

            CommandHelper.ResetColor();
            foreach (ResponseDictionary Channel in Channels)
            {
                CommandHelper.AlternateColor();
                context.WriteLine(" " + Channel["cid"] + "\t" + CommandHelper.Escape(Channel["channel_name"].Replace("\\s", " ")));
            }
            CommandHelper.ResetColor();
            context.Flush();

            return(null);
        }