private static void HandleEventLoop(IrcClient client) { _ircLocaluser = client.LocalUser; _hostNameToWebSockets.Add("", new WebSocketListenerClient(PrivateConstants.TestAccountWebsocketAuth)); _hostNameToWebSockets[""].Run(sendToIrcProcessor); bool isExit = false; while (!isExit) { Console.Write("> "); var command = Console.ReadLine(); switch (command) { case "exit": isExit = true; break; default: if (!string.IsNullOrEmpty(command)) { if (command.StartsWith("/") && command.Length > 1) { client.SendRawMessage(command.Substring(1)); } else { Console.WriteLine($"Unknown command '{command}'"); } } break; } } client.Disconnect(); }
private void SendGreeting(IrcLocalUser localUser, IIrcMessageTarget target) { localUser.SendNotice(target, "This is the {0}, welcome.", ProgramInfo.AssemblyTitle); localUser.SendNotice(target, "Message me with '.help' for instructions on how to use me."); localUser.SendNotice(target, "Remember to log in via a private message and not via the channel."); }
/// <summary> /// </summary> /// <param name="localUser"> /// </param> /// <param name="e"> /// </param> protected abstract void OnLocalUserLeftChannel(IrcLocalUser localUser, IrcChannelEventArgs e);
public static void SendNotice(this IrcLocalUser localUser, IList <IIrcMessageTarget> targets, string format, params object[] args) { localUser.SendNotice(targets, string.Format(format, args)); }
protected virtual void OnLocalUserLeftChannel(IrcLocalUser localUser, IrcChannelEventArgs e) { }
internal void SetLocalUserModes(IrcLocalUser user, string modes) { SendMessageUserMode(user.NickName, modes); }
protected virtual void ResetState() { // Reset fully state of client. this.servers = new Collection<IrcServer>(); this.isRegistered = false; this.localUser = null; this.serverSupportedFeatures = new Dictionary<string, string>(); this.serverSupportedFeaturesReadOnly = new ReadOnlyDictionary<string, string>(this.serverSupportedFeatures); this.channelUserModes = new Collection<char>() { 'o', 'v' }; this.channelUserModesReadOnly = new ReadOnlyCollection<char>(this.channelUserModes); this.channelUserModesPrefixes = new Dictionary<char, char>() { { '@', 'o' }, { '+', 'v' } }; this.motdBuilder = new StringBuilder(); this.networkInformation = new IrcNetworkInfo(); this.channels = new Collection<IrcChannel>(); this.channelsReadOnly = new IrcChannelCollection(this, this.channels); this.users = new Collection<IrcUser>(); this.usersReadOnly = new IrcUserCollection(this, this.users); this.listedChannels = new List<IrcChannelInfo>(); this.listedServerLinks = new List<IrcServerInfo>(); this.listedStatsEntries = new List<IrcServerStatisticalEntry>(); }
protected override void OnLocalUserMessageReceived(IrcLocalUser localUser, IrcMessageEventArgs e) { // }
protected override void OnLocalUserJoinedChannel(IrcLocalUser localUser, IrcChannelEventArgs e) { thisclient.FloodPreventer = new IrcStandardFloodPreventer(2,4000); thisclient.WhoReplyReceived += UserListUpdate; if (xmlprovider.runningVotes().Count() > 0) { VoteTimer = new System.Timers.Timer(5000); VoteTimer.Elapsed += OnVoteTimerEvent; VoteTimer.Enabled = true; } //OnClientRegistered may happen before joined channel thus... _streamProviderManager = new StreamProviderManager(); _streamProviderManager.StreamStarted += OnStreamStarted; _streamProviderManager.StreamStopped += OnStreamStopped; _streamProviderManager.StreamGlobalNotification += OnStreamGlobalNotification; _streamProviderManager.AddStreamProvider(new TwitchProvider()); _streamProviderManager.AddStreamProvider(new HitboxProvider()); //localUser.Client.WhoReplyReceived += WhoReplyReceived; if (reconnectimer != null) { reconnectimer.Dispose(); } if (!debug) { reconnectimer = new System.Timers.Timer(150000); } else { reconnectimer = new System.Timers.Timer(240000); } reconnectimer.Elapsed += OnReconnectTimer; reconnectimer.Enabled = true; }
protected override void OnLocalUserNoticeReceived(IrcLocalUser localUser, IrcMessageEventArgs e) { Trace.TraceInformation("OnLocalUserNoticeReceived: " + e.Text); }
protected override void OnLocalUserMessageReceived(IrcLocalUser localUser, IrcMessageEventArgs e) { if (e.Source.Name != localUser.NickName) Trace.TraceInformation("OnLocalUserMessageReceived: " + e.Text); }
protected override void OnLocalUserLeftChannel(IrcLocalUser localUser, IrcChannelEventArgs e) { Trace.TraceInformation("OnLocalUserLeftChannel"); }
private void HandleClientConnected(IrcRegistrationInfo regInfo) { Logger.WriteLine("Connected to server at '{0}'.", TraceEventType.Verbose,((IPEndPoint)this.socket.RemoteEndPoint).Address); if (regInfo.Password != null) // Authenticate with server using password. SendMessagePassword(regInfo.Password); // Check if client is registering as service or normal user. if (regInfo is IrcServiceRegistrationInfo) { // Register client as service. var serviceRegInfo = (IrcServiceRegistrationInfo)regInfo; SendMessageService(serviceRegInfo.NickName, serviceRegInfo.Distribution, serviceRegInfo.Description); this.localUser = new IrcLocalUser(serviceRegInfo.NickName, serviceRegInfo.Distribution, serviceRegInfo.Description); } else { // Register client as normal user. var userRegInfo = (IrcUserRegistrationInfo)regInfo; SendMessageNick(userRegInfo.NickName); SendMessageUser(userRegInfo.UserName, GetNumericUserMode(userRegInfo.UserModes), userRegInfo.RealName); this.localUser = new IrcLocalUser(userRegInfo.NickName, userRegInfo.UserName, userRegInfo.RealName, userRegInfo.UserModes); } this.localUser.Client = this; // Add local user to list of known users. lock (((ICollection)this.usersReadOnly).SyncRoot) this.users.Add(this.localUser); OnConnected(new EventArgs()); }
protected override void OnLocalUserMessageReceived(IrcLocalUser localUser, IrcMessageEventArgs e) { //Console.WriteLine("{0}", e.Source.ToString()); }
protected override void OnLocalUserJoinedChannel(IrcLocalUser localUser, IrcChannelEventArgs e) { }
protected override void OnLocalUserLeftChannel(IrcLocalUser localUser, IrcChannelEventArgs e) { // }
protected abstract void OnLocalUserQuit(IrcLocalUser localUser, IrcCommentEventArgs e);
protected override void OnLocalUserMessageReceived(IrcLocalUser localUser, IrcMessageEventArgs e) { ReconnectInbound = false; }
protected virtual void HandleClientConnected(IrcRegistrationInfo regInfo) { if (regInfo.Password != null) // Authenticate with server using password. SendMessagePassword(regInfo.Password); // Check if client is registering as service or normal user. if (regInfo is IrcServiceRegistrationInfo) { // Register client as service. var serviceRegInfo = (IrcServiceRegistrationInfo)regInfo; SendMessageService(serviceRegInfo.NickName, serviceRegInfo.Distribution, serviceRegInfo.Description); this.localUser = new IrcLocalUser(serviceRegInfo.NickName, serviceRegInfo.Distribution, serviceRegInfo.Description); } else { // Register client as normal user. var userRegInfo = (IrcUserRegistrationInfo)regInfo; SendMessageNick(userRegInfo.NickName); SendMessageUser(userRegInfo.UserName, GetNumericUserMode(userRegInfo.UserModes), userRegInfo.RealName); this.localUser = new IrcLocalUser(userRegInfo.NickName, userRegInfo.UserName, userRegInfo.RealName, userRegInfo.UserModes); } this.localUser.Client = this; // Add local user to list of known users. lock (((ICollection)this.usersReadOnly).SyncRoot) this.users.Add(this.localUser); OnConnected(new EventArgs()); }
internal void GetLocalUserModes(IrcLocalUser user) { SendMessageUserMode(user.NickName); }
protected virtual void OnLocalUserNoticeReceived(IrcLocalUser localUser, IrcMessageEventArgs e) { }
private void SubscribeToRegisteredClientEvents(IrcLocalUser user) { user.JoinedChannel += OnJoinedChannel; user.MessageReceived += OnMessageReceived; }
protected override void OnLocalUserJoinedChannel(IrcLocalUser localUser, IrcChannelEventArgs e) { ChannelsToRejoin.Add(e.Channel.Name); }
protected virtual void OnLocalUserMessageReceived(IrcLocalUser localUser, IrcMessageEventArgs e) { }
protected override void OnLocalUserLeftChannel(IrcLocalUser localUser, IrcChannelEventArgs e) { if(AutoRejoin) { localUser.Client.Channels.Join(e.Channel.Name); } }
public static void SendMessage(this IrcLocalUser localUser, IIrcMessageTarget target, string format, params object[] args) { SendMessage(localUser, new[] { target }, format, args); }
protected override void OnLocalUserQuit(IrcLocalUser localUser, IrcCommentEventArgs e) { Console.WriteLine("Quit: {0}",e.Comment); }
/// <summary> /// </summary> /// <param name="localUser"> /// </param> /// <param name="e"> /// </param> protected abstract void OnLocalUserNoticeReceived(IrcLocalUser localUser, IrcMessageEventArgs e);
protected override void OnLocalUserJoinedChannel(IrcLocalUser localUser, IrcChannelEventArgs e) { SendGreeting(localUser, e.Channel); }