public void DiscordUserUpdated(object s, DiscordUserUpdatedEventArgs e) { var bridgeUser = UserLinks[e.Current.Username]; if (!DiscordUserConsideredOnline(e.Previous.Status) && DiscordUserConsideredOnline(e.Current.Status)) { IrcLink.SetAway(bridgeUser.IrcUid, false); } else if (DiscordUserConsideredOnline(e.Previous.Status) && !DiscordUserConsideredOnline(e.Current.Status)) { IrcLink.SetAway(bridgeUser.IrcUid, true); } // Join new channels foreach (var channel in e.NewChannels) { IrcLink.JoinChannel(bridgeUser.IrcUserName, Config.DiscordServer.ChannelMapping.FirstOrDefault(x => x.Discord == channel.Id)?.IRC); } // Leave removed channels foreach (var channel in e.RemovedChannels) { IrcLink.PartChannel(bridgeUser.IrcUserName, Config.DiscordServer.ChannelMapping.FirstOrDefault(x => x.Discord == channel.Id)?.IRC); } }
private void JoinDiscordUserToIrcChannel(SocketGuildUser user, Channel link) { UserLink thisLink; if (UserLinks.ContainsKey(user.Username)) { thisLink = UserLinks[user.Username]; } else { thisLink = new UserLink(Config.IRCServer.NicknameSuffix) { BaseUserName = user.Username, DiscordUserName = user.Username, DiscordUserId = user.Id }; thisLink.IrcUid = IrcLink.RegisterNick(thisLink.IrcUserName); UserLinks.Add(user.Username, thisLink); } IrcLink.JoinChannel(thisLink.IrcUserName, link.IRC); }