Пример #1
0
 public override bool Equals(BotUserIdentifier other)
 {
     if (!(other is TelegramBotIdentifier))
     {
         return(false);
     }
     return(user == (other as TelegramBotIdentifier).user);
 }
Пример #2
0
 public override bool Equals(BotUserIdentifier other)
 {
     if (!(other is DiscordBotIdentifier))
     {
         return(false);
     }
     return(id == (other as DiscordBotIdentifier).id);
 }
Пример #3
0
        public static Task ProcessMessage <T>(T bot, BotUserIdentifier user, string msg) where T : BotModel
        {
            return(Task.Run(async() =>
            {
                try
                {
                    BotManager.Instance.Messages.Add(new ChatMessage {
                        ChatBotName = typeof(T).Name, Identification = user.ToString(), RawMessage = msg
                    });

                    var command = msg.Split(' ')[0];
                    var filter = new HashSet <string>();

                    // IsSenario = 0/1
                    // Senario = <string>
                    var option = new Dictionary <string, string>();

                    Log.Logs.Instance.Push("[Bot] Received Message - " + msg + "\r\n" + Log.Logs.SerializeObject(user));

                    UserDBModel userdb = null;
                    var query_user = BotManager.Instance.Users.Where(x => x.ChatBotId == user.ToString()).ToList();
                    if (query_user != null && query_user.Count > 0)
                    {
                        userdb = query_user[0];
                    }

                    switch (command.ToLower())
                    {
                    default:
                        await bot.SendMessage(user, $"'{command}'은/는 적절한 명령어가 아닙니다!\r\n자세한 정보는 '/help' 명령어를 통해 확인해주세요!");
                        break;
                    }
                }
                catch (Exception e)
                {
                    try
                    {
                        Log.Logs.Instance.PushError("[Bot Error] " + e.Message + "\r\n" + e.StackTrace);
                        await bot.SendMessage(user, "서버오류가 발생했습니다! 관리자에게 문의해주세요!");
                    }
                    catch (Exception e2)
                    {
                        Log.Logs.Instance.PushError("[Bot IError] " + e2.Message + "\r\n" + e2.StackTrace);
                    }
                }
            }));
        }
Пример #4
0
        public override Task SendMessage(BotUserIdentifier user, string message)
        {
            //var guild = client.GetGuild(guild_id);
            var embed = new EmbedBuilder();

            embed.Title = "DCInside Archive Bot";
            embed.WithColor(Color.Blue);
            embed.Description = message;
            //embed.Footer = new EmbedFooterBuilder().
            //embed.Url = "https://custom_copy_backendbot.Core.kro.kr";
            //var footer = new EmbedFooterBuilder();
            //footer.Text = "봇 초대 https://custom_copy_backendbot.Core.kro.kr";
            //footer.IconUrl = "https://v.Core.kro.kr";

            //embed.Footer = footer;
            //embed.Fields.Add(new EmbedFieldBuilder { Name = "봇 초대", Value = "https://custom_copy_backendbot.Core.kro.kr" });
            return((client.GetChannel((user as DiscordBotIdentifier).id) as IMessageChannel).SendMessageAsync("", false, embed.Build()));
        }
Пример #5
0
 public override Task SendMessage(BotUserIdentifier user, string message)
 {
     return(bot.SendTextMessageAsync((user as TelegramBotIdentifier).user, message));
 }
Пример #6
0
 public abstract Task SendMessage(BotUserIdentifier user, string message);