Ejemplo n.º 1
0
 private System.Threading.Tasks.Task DiscordClient_MessageReceived(global::Discord.WebSocket.SocketMessage arg)
 {
     if (arg.Channel is IDMChannel)
     {
         var parameters = this.InstanciateParametersForCycle();
         parameters["message"].SetValue(arg.Content);
         parameters["from"].SetValue(arg.Author.Username);
         parameters["messageId"].SetValue(arg.Id);
         this.Graph.AddCycle(this, parameters);
     }
     return(Task.CompletedTask);
 }
        private System.Threading.Tasks.Task DiscordClient_MessageReceived(global::Discord.WebSocket.SocketMessage arg)
        {
            var discordClient = (this.InParameters["discord"].GetValue() as DiscordConnector).DiscordClient;

            var id = ulong.Parse(this.InParameters["channelId"].GetValue().ToString());

            if (arg.Channel is IMessageChannel && arg.Channel.Id == id && arg.Author.Id != discordClient.CurrentUser.Id)
            {
                var parameters = this.InstanciateParametersForCycle();
                var guild      = arg.Channel as SocketGuildChannel;
                parameters["guildId"].SetValue(guild.Guild.Id);
                parameters["channel"].SetValue(arg.Channel.Id);
                parameters["message"].SetValue(arg.Content);
                this.Graph.AddCycle(this, parameters);
            }
            return(Task.CompletedTask);
        }
Ejemplo n.º 3
0
        private System.Threading.Tasks.Task DiscordClient_MessageReceived(global::Discord.WebSocket.SocketMessage arg)
        {
            var message = arg as SocketUserMessage;

            if (message == null)
            {
                return(Task.CompletedTask);
            }


            var discordClient = (this.InParameters["discord"].GetValue() as DiscordConnector).DiscordClient;

            var id = ulong.Parse(this.InParameters["channelId"].GetValue().ToString());

            if (arg.Channel is IMessageChannel && arg.Channel.Id == id && arg.Author.Id != discordClient.CurrentUser.Id)
            {
                int argPos = 0;
                if (!(message.HasCharPrefix(char.Parse(this.InParameters["prefix"].GetValue().ToString()), ref argPos) ||
                      message.HasMentionPrefix(discordClient.CurrentUser, ref argPos)) ||
                    message.Author.IsBot)
                {
                    return(Task.CompletedTask);
                }

                var dispatch = message.Content.Substring(argPos).Split(' ');
                if (dispatch.Length > 0 && dispatch[0].Equals(this.InParameters["command"].GetValue().ToString()))
                {
                    var @params = new List <object>();
                    foreach (var param in dispatch.Skip(1).ToArray())
                    {
                        @params.Add(param);
                    }

                    var parameters = this.InstanciateParametersForCycle();
                    var guild      = arg.Channel as SocketGuildChannel;
                    parameters["guildId"].SetValue(guild.Guild.Id);
                    parameters["channel"].SetValue(arg.Channel.Id);
                    parameters["params"].SetValue(@params);

                    this.Graph.AddCycle(this, parameters);
                }
            }

            return(Task.CompletedTask);
        }