private async Task UserLeftGuild(SocketGuildUser user) { if (user.Guild.Id == Config.GuildId) { OnUserLeave?.Invoke(this, new DiscordUserJoinLeaveEventArgs(user)); EventLog($"{user.Username} has left guild"); } }
private async Task _onuserleaveevent_(RequestResponseModel msg) { ulong user = Convert.ToUInt64(msg.Payload["user_id"]); UserLeaveArgs args = new UserLeaveArgs(user); Task t = Task.Run(() => OnUserLeave?.Invoke(this, args)); Debug.WriteLine($"[EVENT]User left: {user}"); await t; }
private void SessionLeave(USession sees) { Sessions.Remove(sees); OnSessionLeave?.Invoke(sees); if (Sessions.Count < 1) { OnUserLeave?.Invoke(this); } }
public HubForBot() { string url = @"https://twitchlights.xanderapp.com/twitchpipeline"; #if DEBUG url = @"https://localhost:5001/twitchpipeline"; #endif _connection = new HubConnectionBuilder() .WithUrl(url) .WithAutomaticReconnect() .Build(); _connection.On <string, string>("UserJoin", (id, channel) => OnUserJoin?.Invoke(id, channel)); _connection.On <string>("UserLeave", id => OnUserLeave?.Invoke(id)); }
internal void PushCommand(Command cmd) { if (cmd.Source == CommandSource.Client) { return; } switch (cmd.Token) { case "JCH": { var jch = cmd as Server_JCH_ChannelJoin; var character = Connection.GetOrCreateCharacter(jch.Character.Identity); if (!_Characters.Contains(character)) { _Characters.Add(character); } if (!string.IsNullOrEmpty(jch.Title)) { _Title = jch.Title; Joined = true; } else { OnUserJoin?.Invoke(this, new ChannelUserEntryEventArgs(this, character, jch)); } } return; case "LCH": { var lch = cmd as Server_LCH_ChannelLeave; var character = GetCharacter(lch.Character); _Characters.Remove(character); if (character.Name == Connection.LocalCharacter.Name) { Dispose(); } else { OnUserLeave?.Invoke(this, new ChannelUserEntryEventArgs(this, character, lch)); } } return; case "ICH": { var ich = cmd as Server_ICH_ChannelInitialData; _ChannelMode = ich.Mode; Joined = true; foreach (var user in ich.Users) { var ch = GetCharacter(user.Identity); if (!_Characters.Contains(ch)) { _Characters.Add(ch); } } } return; case "COL": { var col = cmd as Server_COL_ChannelGetOPs; foreach (var op in col.OPs) { if (!string.IsNullOrWhiteSpace(op)) { _OPs.Add(GetCharacter(op)); } } } return; case "CDS": { var cds = cmd as Server_CDS_ChannelChangeDescription; OnDescriptionChange?.Invoke(this, new ChannelEntryEventArgs <string>(this, cds.Description, cds)); _Description = cds.Description; } return; case "RMO": { var rmo = cmd as Server_RMO_ChannelSetMode; OnModeChange?.Invoke(this, new ChannelEntryEventArgs <ChannelMode>(this, rmo.Mode, rmo)); _ChannelMode = rmo.Mode; } return; case "CSO": { var cso = cmd as Server_CSO_ChannelSetOwner; OnOwnerChange?.Invoke(this, new ChannelEntryEventArgs <Character>(this, GetCharacter(cso.Character), cso)); _OwnerName = cso.Character; } return; case "RST": { var rst = cmd as Server_RST_ChannelSetStatus; OnStatusChange?.Invoke(this, new ChannelEntryEventArgs <ChannelStatus>(this, rst.Status, rst)); _Status = rst.Status; } return; case "COA": { var coa = cmd as Server_COA_ChannelMakeOP; var character = GetCharacter(coa.Character); _OPs.Add(character); OnOPAdded?.Invoke(this, new ChannelUserEntryEventArgs(this, character, coa)); } return; case "COR": { var cor = cmd as Server_COR_ChannelRemoveOP; var character = GetCharacter(cor.Character); _OPs.Remove(character); OnOPRemoved?.Invoke(this, new ChannelUserEntryEventArgs(this, character, cor)); } return; case "CKU": { var cku = cmd as Server_CKU_ChannelKickCharacter; var character = GetCharacter(cku.Character); _Characters.Remove(character); OnUserKicked?.Invoke(this, new ChannelAdminActionEventArgs(this, character, GetCharacter(cku.OP), cku)); } return; case "CBU": { var cbu = cmd as Server_CBU_ChannelBanCharacter; var character = GetCharacter(cbu.Character); _Characters.Remove(character); _Banlist.Add(character); OnUserBanned?.Invoke(this, new ChannelAdminActionEventArgs(this, character, GetCharacter(cbu.OP), cbu)); } return; case "CUB": { var cub = cmd as Server_CUB_ChannelUnbanCharacter; var character = GetCharacter(cub.Character); _Banlist.Remove(character); OnUserUnbanned?.Invoke(this, new ChannelAdminActionEventArgs(this, character, GetCharacter(cub.OP), cub)); } return; case "CTU": { var ctu = cmd as Server_CTU_ChannelTimeoutCharacter; var character = GetCharacter(ctu.Character); _Characters.Remove(character); OnUserTimedout?.Invoke(this, new ChannelAdminActionEventArgs(this, character, GetCharacter(ctu.OP), ctu)); } return; case "MSG": { var msg = cmd as Server_MSG_ChannelChatMessage; OnChatMessage?.Invoke(this, new ChannelUserMessageEventArgs(this, GetCharacter(msg.Character), msg.Message, msg)); } return; case "LRP": { var lrp = cmd as Server_LRP_ChannelLFRPMessage; OnLFRPMessage?.Invoke(this, new ChannelUserMessageEventArgs(this, GetCharacter(lrp.Character), lrp.AD, lrp)); } return; case "RLL": { var rll = cmd as Server_RLL_ChannelRollMessage; OnRollMessage?.Invoke(this, new ChannelUserMessageEventArgs(this, GetCharacter(rll.Character), rll.Message, rll)); } return; case "SYS": { var sys = cmd as Server_SYS_ChatSYSMessage; OnSYSMessage?.Invoke(this, new ChannelEntryEventArgs <string>(this, sys.Message, sys)); } return; } }
public void UserLeave(UserLeavedTransportModel obj) { OnUserLeave?.Invoke(this, obj.Mapping <UserLeavedEventArgs>()); }