Пример #1
0
        private async Task ReactionAdded(Cacheable <IUserMessage, ulong> msg, ISocketMessageChannel channel, SocketReaction reaction)
        {
            IMessage message = await msg.GetOrDownloadAsync();

            switch (message.Embeds.Count)
            {
            case 0:
                break;      // might do something with this eventually

            case 1:
                IEmbed embed = message.Embeds.ElementAt <IEmbed>(0);
                if (embed.Footer.ToString() == "React-for-Role Embed" && reaction.UserId != _client.CurrentUser.Id)
                {
                    await ReactForRole.RfrAddRoleAsync(embed, reaction);

                    break;
                }
                if (embed.Footer.ToString().Substring(0, 4) == "Vote" && reaction.UserId != _client.CurrentUser.Id)
                {
                    await VoteModule.AddVote(message as IUserMessage, reaction);

                    break;
                }
                break;

            default:
                break;
            }
        }
Пример #2
0
        public void InlineMenu(InlineQuery query, IBot Parent)
        {
            if (Parent.Modules.Exists(fn => fn.Name == "_2chModule") && query.Query.Contains("2ch"))
            {
                Webm webm = Parent.GetModule <_2chModule>().WebmsSent.Find(fn => fn.Path == query.Query);
                if (webm != null)
                {
                    var msg = new Telegram.Bot.Types.InlineQueryResults.InputTextMessageContent($"<a href=\"{ webm.Thumbnail }\">&#8204;</a>{webm.Path}")
                    {
                        ParseMode = Telegram.Bot.Types.Enums.ParseMode.Html
                    };

                    Telegram.Bot.Types.InlineQueryResults.InlineQueryResultArticle[] results =
                    {
                        new Telegram.Bot.Types.InlineQueryResults.InlineQueryResultArticle("0", "WEBM", msg)
                        {
                            ReplyMarkup = LikeDislikeModule.getKeyBoard(),
                            Description = "POST"
                        }
                    };
                    Parent.Client.AnswerInlineQueryAsync(query.Id, results);
                }
            }
            else if (query.Query.Contains("opros"))
            {
                string id = query.Query.Split('-').Last();
                try
                {
                    var Oprs = Parent.GetModule <VoteModule>().Opros.Find(fn => fn.Id == int.Parse(id));
                    if (Oprs != null)
                    {
                        var msg = new Telegram.Bot.Types.InlineQueryResults.InputTextMessageContent($"{Oprs.About}")
                        {
                            ParseMode = Telegram.Bot.Types.Enums.ParseMode.Html
                        };

                        Pes7BotCrator.Modules.Types.VoteModule.Likes ll = null;
                        try
                        {
                            ll = Parent.GetModule <VoteModule>().LLikes.Find(fn => fn.ParentO.Id == int.Parse(id));
                        }
                        catch { }
                        Telegram.Bot.Types.InlineQueryResults.InlineQueryResultArticle[] results =
                        {
                            new Telegram.Bot.Types.InlineQueryResults.InlineQueryResultArticle("0", "Opros",            msg)
                            {
                                ReplyMarkup = VoteModule.getKeyBoard(ll.LikeId.Count,               ll.DisLikeId.Count, Oprs,Oprs.Query),
                                Description = "POST"
                            }
                        };
                        Parent.Client.AnswerInlineQueryAsync(query.Id, results);
                    }
                }
                catch {}
            }
        }