Exemplo n.º 1
0
        public ResponserPlugin(DezClient client) : base(client, "ResponserPlugin")
        {
            Command = new Command[] { new Command("nsfw", "Allows/disables NSFW mode for responsed", this, (msg, args) =>
                {
                    if (!_rssccol.getByServer(msg.Server, true).nsfw)
                    {
                        _rssccol.getByServer(msg.Server).nsfw = true;
                        return("NSFW ACTIVATED! ( ͡° ͜ʖ ͡°)");
                    }
                    else
                    {
                        _rssccol.getByServer(msg.Server).nsfw = false;
                        return("NSFW disabled");
                    }
                }) };
            Command[0].SetRequiredRole("P**n Summoner");

            _rssccol = new ResponserServerSettingsCollection();
            _trcol   = new TriggerWordCollection();

            _client.MessageReceived += async(s, e) =>
            {
                if (!e.Message.IsAuthor && e.Message.Text != "" && e.Message.Text.ToCharArray()[0] != '?')
                {
                    string ret = HandleMessage(e.Message);
                    if (ret != null)
                    {
                        await e.Channel.SendMessage(ret);
                    }
                }
            };
        }
Exemplo n.º 2
0
        public void Start(string[] args)
        {
            _client = new DezClient();

            ColoredConsole.WriteLine("Creating event handlers!", fgcolor: ConsoleColor.Green);

            _client.MessageReceived += async(s, e) =>
            {
                if (!e.Message.IsAuthor && e.Message.Text != "" && e.Message.Text.ToCharArray()[0] == '?' && e.Message.Text != "?")
                {
                    string rt = _client.PluginManager.SendCommand(e.Message);
                    if (rt != null && rt != "")
                    {
                        await e.Channel.SendMessage(rt);
                    }
                }
            };

            ColoredConsole.WriteLine("Loading plugins!", fgcolor: ConsoleColor.Green);
            _client.PluginManager.AddPlugin(new BasicFunctionsPlugin(_client));                        //BASIC FUNCTIONS PLUGIN
            _client.PluginManager.AddPlugin(new AudioPlugin.AudioPlugin(_client));                     //AUDIO PLUGIN
            _client.PluginManager.AddPlugin(new UrbanDictionaryPlugin.UrbanDictionaryPlugin(_client)); //UD PLUGIN
            _client.PluginManager.AddPlugin(new ResponserPlugin(_client));                             //RESPONSER PLUGIN
            _client.PluginManager.AddPlugin(new DebuggerPlugin.DebuggerPlugin(_client));

            ColoredConsole.WriteLine("Loading Reponse Triggers", fgcolor: ConsoleColor.Green);

            string fld = (_client.PluginManager.GetPluginByClass <ResponserPlugin>().LoadTriggersFromFile("Resources/Triggers.xml")) ?  "File Loaded" : "Created template file!";

            ColoredConsole.WriteLine(fld, fgcolor: ConsoleColor.Green);
            ColoredConsole.WriteLine("Connecting!", fgcolor: ConsoleColor.Green);

            _client.Ready += (s, e) =>
            {
                _client.SetGame("http://dezrodino.mzf.cz/");
            };

            _client.DebugModeChanged += (s, e) =>
            {
                string state = (e.DebugModeState) ? "activated" : "deactivated";
                ColoredConsole.WriteLine("Debug mode " + state, fgcolor: ConsoleColor.Yellow);
            };

            _client.ExceptionCaught += (s, e) =>
            {
                ColoredConsole.WriteLine(e.e.ToString(), fgcolor: ConsoleColor.Red);
            };

            _client.ExecuteAndWait(async() =>
            {
                await _client.Connect(conneciton_token, Discord.TokenType.Bot);
            });
        }
Exemplo n.º 3
0
 public Plugin(DezClient client, string Name)
 {
     this._client = client;
     this.Name    = Name;
 }
Exemplo n.º 4
0
 public PluginManager(DezClient _client)
 {
     this._client       = _client;
     _plcol             = new PluginCollection();
     RegisteredCommands = new CommandCollection();
 }
Exemplo n.º 5
0
        public BasicFunctionsPlugin(DezClient client) : base(client, "BasicFunctionsPlugin")
        {
            Command = new Command[] { new Command("help", "List all availible commands", this, (m, args) =>
                {
                    string helpmsg = "Availible commands:\n";
                    foreach (Command cmd in _client.PluginManager.RegisteredCommands)
                    {
                        helpmsg += "**`?" + cmd.Name + " - " + cmd.Description + "`**  ";
                    }
                    return(helpmsg);
                }),
                                      new Command("insult", "Insults user", this, (m, args) =>
                {
                    string user;
                    string sender = m.User.Name;

                    if (args.Length == 0)
                    {
                        user = sender;
                    }
                    else
                    {
                        user = args[0];
                    }

                    if (user.ToLower().Contains("dezbot"))
                    {
                        return("Can't insult myself you dumb f**k!");
                    }

                    if (user.ToLower().Contains("dezrodino"))
                    {
                        return("Who'd want to insult such an awesome person!?");
                    }



                    return(Insulter.Insult(user, sender));
                }),
                                      new Command("purge", "Clears bot's messages", this, (m, args) =>
                {
                    if (args.Length == 0)
                    {
                        return("Usage: ?purge [ammount]");
                    }
                    int amm;
                    if (!int.TryParse(args[0], out amm))
                    {
                        return("Ammount has to be integer!");
                    }

                    int rtr  = 1;
                    int fnds = 0;
                    var msgs = m.Channel.Messages;
                    int ct   = msgs.Count();
                    if (ct < amm)
                    {
                        amm = ct;
                    }
                    while ((fnds < amm && rtr < ct))
                    {
                        if (msgs.ElementAt(ct - rtr).IsAuthor)
                        {
                            msgs.ElementAt(ct - rtr).Delete();
                            fnds++;
                        }
                        rtr++;
                    }
                    return(null);
                }),
                                      new Command("clear", "Clears messages", this, (m, args) =>
                {
                    if (args.Length == 0)
                    {
                        return("Usage: ?clear [ammount] (user)...");
                    }

                    int amm;
                    if (!int.TryParse(args[0], out amm))
                    {
                        return("Ammount has to be integer!");
                    }

                    amm++;


                    var tsk = m.Channel.DownloadMessages();
                    tsk.Wait();
                    var msgs = tsk.Result;

                    int rtr  = 0;
                    int fnds = 0;
                    int ct   = msgs.Length;

                    if (ct < amm)
                    {
                        amm = ct;
                    }
                    string user = null;
                    if (args.Length >= 2)
                    {
                        user = args[1];
                    }
                    while ((fnds < amm && rtr < ct - 1))
                    {
                        if (user != null)
                        {
                            if (user == msgs.ElementAt(rtr).User.Name)
                            {
                                msgs.ElementAt(rtr).Delete();
                                fnds++;
                            }
                        }
                        else
                        {
                            msgs.ElementAt(rtr).Delete();
                            fnds++;
                        }
                        rtr++;
                    }
                    return(null);
                }
                                                  ) };
            Command[2].SetRequiredRole("Bot Slaver");
            Command[3].SetRequiredRole("Bot Slaver");
        }