コード例 #1
0
        public async Task TradeById(SocketMessage msg, string[] args)
        {
            var trade = await ResponseGrabber.SendMessageAndGrabResponse(
                (ITextChannel)msg.Channel,
                $"{Configuration.PokecordPrefix}trade <@{Configuration.OwnerID}>",
                x => MessagePredicates.TradeMessage(x, msg),
                5
                );

            await Task.Delay(3000);

            if (trade == null)
            {
                await msg.Channel.SendMessageAsync("p!cancel");

                return;
            }

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add {String.Join(' ', args)}");

            await Task.Delay(1000);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}confirm");

            await Task.Delay(1500);
        }
コード例 #2
0
        public async Task TradeById(SocketMessage msg, string[] args)
        {
            if (args.Length != 1)
            {
                await msg.Channel.SendMessageAsync("Invalid arguments. Please supply an ID.");

                return;
            }

            var trade = await ResponseGrabber.SendMessageAndGrabResponse(
                (ITextChannel)msg.Channel,
                $"{Configuration.PokecordPrefix}trade <@{Configuration.OwnerID}>",
                x => MessagePredicates.TradeMessage(x, msg),
                5
                );

            await Task.Delay(1500);

            if (trade == null)
            {
                await msg.Channel.SendMessageAsync("Pokecord didn't create trade, aborting.");

                return;
            }

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add {args[0]}");

            await Task.Delay(1500);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}confirm");

            await Task.Delay(1500);
        }
コード例 #3
0
        public async Task Trade200(SocketMessage msg, string[] args)
        {
            var trade = await ResponseGrabber.SendMessageAndGrabResponse(
                (ITextChannel)msg.Channel,
                $"{Configuration.PokecordPrefix}trade <@{Configuration.OwnerID}>",
                x => MessagePredicates.TradeMessage(x, msg),
                5
                );

            await Task.Delay(3000);

            if (trade == null)
            {
                await msg.Channel.SendMessageAsync("p!cancel");

                return;
            }

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25");

            await Task.Delay(1523);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50");

            await Task.Delay(1927);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75");

            await Task.Delay(1750);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100");

            await Task.Delay(1853);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125");

            await Task.Delay(2836);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150");

            await Task.Delay(1457);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175");

            await Task.Delay(1953);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200");

            await Task.Delay(2563);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}confirm");

            await Task.Delay(1636);
        }
コード例 #4
0
        public async Task Trade(SocketMessage msg, string[] args)
        {
            var list = await ResponseGrabber.SendMessageAndGrabResponse(
                (ITextChannel)msg.Channel,
                $"{Configuration.PokecordPrefix}pokemon --name {String.Join(' ', args)}",
                x => MessagePredicates.PokemonListingMessage(x, msg),
                5
                );

            await Task.Delay(2000);

            if (list == null)
            {
                await msg.Channel.SendMessageAsync("Pokecord didn't display pokemon, aborting.");

                return;
            }

            var pokemans = Util.ParsePokemonListing(list.Embeds.First().Description);

            await Task.Delay(1500);

            var trade = await ResponseGrabber.SendMessageAndGrabResponse(
                (ITextChannel)msg.Channel,
                $"{Configuration.PokecordPrefix}trade <@{Configuration.OwnerID}>",
                x => MessagePredicates.TradeMessage(x, msg),
                5
                );

            await Task.Delay(2000);

            if (trade == null)
            {
                await msg.Channel.SendMessageAsync("Pokecord didn't create trade, aborting.");

                return;
            }

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add {String.Join(' ', pokemans.Select(x => x.Id))}");

            await Task.Delay(1500);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}confirm");

            await Task.Delay(1500);
        }
コード例 #5
0
        public async Task Trade(SocketMessage msg, string[] args)
        {
            var list = await ResponseGrabber.SendMessageAndGrabResponse(
                (ITextChannel)msg.Channel,
                $"{Configuration.PokecordPrefix}pokemon --name {String.Join(' ', args)}",
                x => x.Channel.Id == msg.Channel.Id && x.Author.Id == PokecordCatcher.POKECORD_ID && x.Embeds.Count > 0 && x.Embeds.First().Title?.StartsWith("Your") == true,
                5
                );

            if (list == null)
            {
                await msg.Channel.SendMessageAsync("Pokecord didn't display pokemon, aborting.");

                return;
            }

            var pokemans = Util.ParsePokemonListing(list.Embeds.First().Description);

            await Task.Delay(1500);

            var trade = await ResponseGrabber.SendMessageAndGrabResponse(
                (ITextChannel)msg.Channel,
                $"{Configuration.PokecordPrefix}trade <@{Configuration.OwnerID}>",
                x => x.Channel.Id == msg.Channel.Id && x.Author.Id == PokecordCatcher.POKECORD_ID && x.Embeds.Count > 0 && x.Embeds.First().Title?.StartsWith("Trade between ") == true,
                5
                );

            await Task.Delay(1500);

            if (trade == null)
            {
                await msg.Channel.SendMessageAsync("Pokecord didn't create trade, aborting.");

                return;
            }

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add {String.Join(' ', pokemans.Select(x => x.Id))}");

            await Task.Delay(1500);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}confirm");

            await Task.Delay(1500);
        }
コード例 #6
0
        public async Task Trade100(SocketMessage msg, string[] args)
        {
            var trade = await ResponseGrabber.SendMessageAndGrabResponse(
                (ITextChannel)msg.Channel,
                $"{Configuration.PokecordPrefix}trade <@{Configuration.OwnerID}>",
                x => MessagePredicates.TradeMessage(x, msg),
                5
                );

            await Task.Delay(3000);

            if (trade == null)
            {
                await msg.Channel.SendMessageAsync("p!cancel");

                return;
            }

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25");

            await Task.Delay(1523);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50");

            await Task.Delay(1927);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75");

            await Task.Delay(1750);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100");

            await Task.Delay(1853);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}confirm");

            await Task.Delay(1582);
        }
コード例 #7
0
        private async Task OnMessage(SocketMessage msg)
        {
            var guild = ((SocketGuildChannel)msg.Channel).Guild;

            if (State.WhitelistGuilds && !Configuration.WhitelistedGuilds.Contains(guild.Id))
            {
                return;
            }

            if (msg.Author.Id != PokecordCatcher.POKECORD_ID || msg.Embeds?.Count == 0)
            {
                return;
            }

            Embed embed = msg.Embeds.First();

            if (embed.Description?.Contains(Configuration.PokecordPrefix + "catch") != true || !embed.Image.HasValue)
            {
                return;
            }

            Console.WriteLine("Detected pokemon, catching...");

            var watch = System.Diagnostics.Stopwatch.StartNew();

            string name = comparer.GetPokemon(await http.GetStreamAsync(embed.Image.Value.Url));

            watch.Stop();

            Console.WriteLine($"Found pokemon in {watch.ElapsedMilliseconds}ms");

            if (State.WhitelistPokemon && !Configuration.WhitelistedPokemon.Any(x => x.Equals(name, StringComparison.OrdinalIgnoreCase)))
            {
                Console.WriteLine("Pokemon is not whitelisted, ignoring.");
                Logger.Log($"Ignored a {name} in #{msg.Channel.Name} ({guild.Name})");
                return;
            }

            if (Configuration.CatchMinDelay > 0)
            {
                int delay = Util.rand.Next(Configuration.CatchMinDelay, Configuration.CatchMaxDelay);
                Console.WriteLine($"Delaying for {delay}ms before catching the pokemon...");
                await Task.Delay(delay);
            }

            var resp = await ResponseGrabber.SendMessageAndGrabResponse(
                (ITextChannel)msg.Channel,
                $"{Configuration.PokecordPrefix}catch {name}",
                x => MessagePredicates.SuccessfulCatchMessage(x, msg, Client.CurrentUser.Id),
                5
                );

            Console.WriteLine(resp == null ? "The Pokecord bot did not respond, catch was a fail." : "Catch confirmed by the Pokecord bot.");

            if (resp != null)
            {
                if (Configuration.EnableCatchResponse)
                {
                    await msg.Channel.SendMessageAsync(Configuration.CatchResponse);
                }

                Logger.Log($"Caught a {name} in #{resp.Channel.Name} ({guild.Name})");
            }
            else
            {
                Logger.Log($"Failed to catch {name} in #{msg.Channel.Name} ({guild.Name})");
            }

            Console.WriteLine();
        }
コード例 #8
0
        public async Task Trade325(SocketMessage msg, string[] args)
        {
            var trade = await ResponseGrabber.SendMessageAndGrabResponse(
                (ITextChannel)msg.Channel,
                $"{Configuration.PokecordPrefix}trade <@{Configuration.OwnerID}>",
                x => MessagePredicates.TradeMessage(x, msg),
                5
                );

            await Task.Delay(3000);

            if (trade == null)
            {
                await msg.Channel.SendMessageAsync("p!cancel");

                return;
            }

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25");

            await Task.Delay(1523);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50");

            await Task.Delay(1927);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75");

            await Task.Delay(1750);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100");

            await Task.Delay(1853);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125");

            await Task.Delay(2534);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150");

            await Task.Delay(1463);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175");

            await Task.Delay(2684);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200");

            await Task.Delay(1636);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225");

            await Task.Delay(2337);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250");

            await Task.Delay(1478);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275");

            await Task.Delay(1735);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300");

            await Task.Delay(1468);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}p add 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325");

            await Task.Delay(1735);

            await msg.Channel.SendMessageAsync($"{Configuration.PokecordPrefix}confirm");

            await Task.Delay(1736);
        }