예제 #1
0
        private void BotClient_OnMessage(object sender, Telegram.Bot.Args.MessageEventArgs e)
        {
            if (e.Message.Type != MessageType.Text || e.Message.Chat.Type == ChatType.Private)
            {
                return;
            }

            var relay = Settings.TelegramModule.RelayChannels.FirstOrDefault(a => a.Telegram == e.Message.Chat.Id);

            if (relay == null)
            {
                return;
            }
            if (relay.Discord == 0 || IsMessagePooled(e.Message.Text) || relay.TelegramFilters.Any(e.Message.Text.Contains) || relay.TelegramFiltersStartsWith.Any(e.Message.Text.StartsWith))
            {
                return;
            }

            var from = string.IsNullOrEmpty(e.Message.From.Username) ? $"{e.Message.From.FirstName} {e.Message.From.LastName}" : e.Message.From.Username;

            if (relay.TelegramUsers.Count > 0 && !relay.TelegramUsers.Contains(from))
            {
                return;
            }

            var msg = $"[TM][{from}]: {e.Message.Text}";

            UpdatePool(msg);
            RelayMessage?.Invoke(msg, relay.Discord);
        }
예제 #2
0
        private void IRC_Message(UserInfo userinfo, string channel, string message)
        {
            var relay = Settings.IrcModule.RelayChannels.FirstOrDefault(a => a.IRC == channel);

            if (relay == null)
            {
                return;
            }
            if (relay.Discord == 0 || IsMessagePooled(message) || relay.IRCFilters.Any(message.Contains) || relay.IRCFiltersStartsWith.Any(message.StartsWith))
            {
                return;
            }
            if (relay.IRCUsers.Count > 0 && !relay.IRCUsers.Contains(userinfo.Nickname))
            {
                return;
            }

            var msg = $"[IRC][{userinfo.Nickname}]: {message}";

            UpdatePool(msg);
            RelayMessage?.Invoke(msg, relay.Discord);
        }
예제 #3
0
        private void BotClient_OnMessage(object sender, Telegram.Bot.Args.MessageEventArgs e)
        {
            if (e.Message.Type != MessageType.Text || e.Message.Chat.Type == ChatType.Private || !APIHelper.IsDiscordAvailable)
            {
                return;
            }

            if (!Settings.TelegramModule.RelayFromTelegram)
            {
                return;
            }

            var relay = Settings.TelegramModule.RelayChannels.FirstOrDefault(a => a.Telegram == e.Message.Chat.Id);

            if (relay == null)
            {
                return;
            }
            if (relay.Discord == 0 || IsMessagePooled(e.Message.Text) || relay.TelegramFilters.Any(e.Message.Text.Contains) || relay.TelegramFiltersStartsWith.Any(e.Message.Text.StartsWith))
            {
                return;
            }

            var fromNick = $"{e.Message.From.FirstName} {e.Message.From.LastName}";
            var fromName = e.Message.From.Username;

            if (relay.TelegramUsers.Count > 0 && !relay.TelegramUsers.Contains(fromName) && !relay.TelegramUsers.Contains(fromNick))
            {
                return;
            }

            var name = string.IsNullOrWhiteSpace(fromNick) ? fromName : fromNick;
            var msg  = $"[TM][{name}]: {e.Message.Text}";

            UpdatePool(msg);
            RelayMessage?.Invoke(msg, relay.Discord);
        }