public void Execute(IrcClient Client, string channel, IrcUser Sender, string message) { message = message.Trim(); if (message == "") { Client.LocalUser.SendMessage(channel, horoscopeHelpMsg()); } else { if (!signs.ContainsKey(message)) { Client.LocalUser.SendMessage(channel, "Why won't you give me a sign~"); return; } string html = getHTML(signs[message]); string horoscope = dropHtmlPrecedingHoroscope(html, message); horoscope = dropHtmlTailingHoroscope(horoscope); horoscope = html2Txt(horoscope); Client.LocalUser.SendMessage(channel, horoscope); } }
public IRCCommandEventArgs(string text, IrcUser sender, IIrcMessageTarget target) { parameters = IRCCommands.ParseParameters(text); RawText = text; Sender = sender; Target = target; }
public TwitterBotUser(IrcUser ircUser) : this() { Debug.Assert(ircUser != null); this.IrcUser = ircUser; }
/// <summary> /// Initializes a new instance of the <see cref="IrcChannelInvitationEventArgs"/> class. /// </summary> /// <param name="channel">The channel to which the recipient user is invited.</param> /// <param name="inviter">The user inviting the recipient user to the channel.</param> public IrcChannelInvitationEventArgs(IrcChannel channel, IrcUser inviter) : base(channel) { if (inviter == null) throw new ArgumentNullException("inviter"); this.Inviter = inviter; }
internal IrcChannelUser(IrcUser user, IEnumerable<char> modes = null) { this.user = user; this.modes = new HashSet<char>(); this.modesReadOnly = new ReadOnlySet<char>(this.modes); if (modes != null) this.modes.AddRange(modes); }
internal void HandleModesChanged(IrcUser source, string newModes, IEnumerable <string> newModeParameters) { lock (((ICollection)this.modesReadOnly).SyncRoot) this.modes.UpdateModes(newModes, newModeParameters, this.client.ChannelUserModes, (add, mode, modeParameter) => this.users.Single( cu => cu.User.NickName == modeParameter).HandleModeChanged(add, mode)); OnModesChanged(new IrcUserEventArgs(source)); }
/// <summary> /// Gets the <see cref="IrcChannelUser"/> in the channel that corresponds to the specified /// <see cref="IrcUser"/>, or <see langword="null"/> if none is found. /// </summary> /// <param name="user">The <see cref="IrcUser"/> for which to look.</param> /// <returns>The <see cref="IrcChannelUser"/> in the channel that corresponds to the specified /// <see cref="IrcUser"/>, or <see langword="null"/> if none is found.</returns> /// <exception cref="ArgumentNullException"><paramref name="user"/> is <see langword="null"/>.</exception> public IrcChannelUser GetChannelUser(IrcUser user) { if (user == null) { throw new ArgumentNullException("user"); } return(this.users.SingleOrDefault(cu => cu.User == user)); }
/// <summary> /// Initializes a new instance of the <see cref="IrcChannelInvitationEventArgs"/> class. /// </summary> /// <param name="channel">The channel to which the recipient user is invited.</param> /// <param name="inviter">The user inviting the recipient user to the channel.</param> public IrcChannelInvitationEventArgs(IrcChannel channel, IrcUser inviter) : base(channel) { if (inviter == null) { throw new ArgumentNullException("inviter"); } this.Inviter = inviter; }
/// <summary> /// Initializes a new instance of the <see cref="IrcUserEventArgs"/> class. /// </summary> /// <param name="user">The user that the event concerns.</param> public IrcUserEventArgs(IrcUser user, string comment) : base(comment) { if (user == null) { throw new ArgumentNullException("user"); } this.User = user; }
protected override void OnChannelModeChanged(IrcChannel channel, IrcUser source, string newModes, IEnumerable<string> newModeParameters) { // Twitch doesn't actually send JOIN messages. This means we need to add users // to the channel when changing their mode if we haven't already. foreach (string username in newModeParameters) { IrcUser user = GetUserFromNickName(username); if (channel.GetChannelUser(user) == null) channel.HandleUserJoined(new IrcChannelUser(user)); } }
public IrcQueryViewModel(IrcUser user, IrcClient client, Settings settings) { this.Settings = settings; this.User = user; this.client = client; this.DisplayName = user.NickName; this.Messages = new BindableCollection<Message>(); this.Closable = true; // TODO this.client.LocalUser.MessageReceived += this.messageReceived; }
internal IrcChannelUser(IrcUser user, IEnumerable <char> modes = null) { User = user; this.modes = new HashSet <char>(); Modes = new ReadOnlySet <char>(this.modes); if (modes != null) { this.modes.AddRange(modes); } }
private TwitterBotUser GetTwitterBotUser(IrcUser ircUser) { var twitterUser = this.twitterUsers.SingleOrDefault(tu => tu.IrcUser == ircUser); if (twitterUser == null) { throw new InvalidOperationException(string.Format( "User '{0}' is not logged in to Twitter.", ircUser.NickName)); } return(twitterUser); }
protected override void OnChannelModeChanged(IrcChannel channel, IrcUser source, string newModes, IEnumerable <string> newModeParameters) { // Twitch doesn't actually send JOIN messages. This means we need to add users // to the channel when changing their mode if we haven't already. foreach (string username in newModeParameters) { IrcUser user = GetUserFromNickName(username); if (channel.GetChannelUser(user) == null) { channel.HandleUserJoined(new IrcChannelUser(user)); } } }
public void Run(IrcClient client, IIrcMessageSource source, IList<IIrcMessageTarget> targets, string command, IList<string> parameters) { Client = client; SourceUser = (IrcUser)source; Command = command; Parameters = parameters; if (targets.Contains(Client.LocalUser) && source != null) ReplyTargets = new[] { (IIrcMessageTarget)source }; else { ReplyTargets = targets; } Run(); }
public void Execute(IrcDotNet.IrcClient Client, string Channel, IrcDotNet.IrcUser Sender, string Message) { // Message sisältää argumentit // Jos Message on tyhjä, niin komennolle ei ole annettu argumentteja // Esimerkki: // !uguu -> Message on tyhjä // !uguu Crank -> Message == "Crank" // uguu u:kirjainten määrä vaihtelee satunnaisesti 2-17 välillä string text = ""; string uguu = "uu"; IrcUserCollection nicklist = Client.Channels.Client.Users; Random random = new Random(); if (Message == "") { int rnd = random.Next(0, 16); for (int i = 0; i < rnd; i++) { uguu += 'u'; } uguu += '~'; //string[] IllegalNicks = { "SIMOBOT", Sender.NickName}; int rndNick = random.Next(0, nicklist.Count); text = nicklist[rndNick].NickName.TrimEnd("aeiouyåäö".ToCharArray()) + uguu; } else { Message = Message.Trim().TrimEnd("aeiouyåäö".ToCharArray()); int rnd = random.Next(0, 16); for (int i = 0; i < rnd; i++) { uguu += 'u'; } uguu += '~'; text = Message + uguu; } Client.LocalUser.SendMessage(Channel, text); }
public LevelSubmission(string levelID, IrcUser user, bool forceAdd) { //If you are force adding the level, bypass error checking, formatting and API call. if (!forceAdd) { if (!IsValidLevelCode(levelID)) throw new ArgumentException("Invalid level code format"); LevelID = FormatLevelCode(levelID); Level = SMMApi.GetLevel(LevelID); if (Level == null) throw new ArgumentException("Level does not exist"); } else LevelID = levelID; //Initiaze variables User = user; IsPlayed = false; IsQueued = false; }
internal void HandleInviteReceived(IrcUser inviter, IrcChannel channel) { OnInviteReceived(new IrcChannelInvitationEventArgs(channel, inviter)); }
public static void Execute(string str, IrcUser sender, IIrcMessageTarget target) { var args = new IRCCommandEventArgs(str, sender, target); string commandName = args[-1].ToLowerInvariant(); if (TShockIRC.Config.IgnoredCommands.Contains(commandName)) return; var ircCommand = Commands.FirstOrDefault(c => c.Names.Contains(commandName)); var senderGroup = TShockIRC.IrcUsers[sender]; if (ircCommand != null) { if (String.IsNullOrEmpty(ircCommand.Permission) || senderGroup.HasPermission(ircCommand.Permission)) { if (ircCommand.DoLog) Log.Info("{0} executed: /{1}.", sender.NickName, str); ircCommand.Execute(args); } else { Log.Warn("{0} tried to execute /{1}.", sender.NickName, str); TShockIRC.SendMessage(target, "\u00035You do not have access to this command."); } } else if (senderGroup.HasPermission("tshockirc.command")) { var tsIrcPlayer = new TSIrcPlayer(sender.NickName, senderGroup, target); var commands = TShockAPI.Commands.ChatCommands.Where(c => c.HasAlias(commandName)); if (commands.Count() != 0) { Main.rand = new Random(); WorldGen.genRand = new Random(); foreach (Command command in commands) { if (!command.CanRun(tsIrcPlayer)) { Log.Warn("{0} tried to execute /{1}.", sender.NickName, str); TShockIRC.SendMessage(target, "\u00035You do not have access to this command."); } else if (!command.AllowServer) TShockIRC.SendMessage(target, "\u00035You must use this command in-game."); else { var parms = args.ParameterRange(0, args.Length); if (TShockAPI.Hooks.PlayerHooks.OnPlayerCommand(tsIrcPlayer, command.Name, str, parms, ref commands)) return; if (command.DoLog) Log.Info("{0} executed: /{1}.", sender.NickName, str); command.Run(str, tsIrcPlayer, parms); } } } else TShockIRC.SendMessage(target, "\u00035Invalid command."); } else { Log.Warn("{0} tried to execute /{1}.", sender.NickName, str); TShockIRC.SendMessage(target, "\u00035You do not have access to this command."); } }
// TODO: Kog 11/23/2009 - Refactor this into some sort of multi-network arrangement. /// <summary> /// A convenience method for checking if we've received the notice we're blocking on from a services agent. /// </summary> /// /// <param name="notice">The notice to digest.</param> /// <param name="user">The user sending the notice.</param> /// /// <returns>True if we've been responded to by a services agent, else false.</returns> private bool NoticeIsExpectedServicesAgentMessage(IrcUser user, string notice) { // Make sure the message is coming from NickServ if (user.NickName.Equals("nickserv", StringComparison.OrdinalIgnoreCase)) { return notice.StartsWith("You are now identified for", StringComparison.OrdinalIgnoreCase) || (notice.StartsWith("The nickname", StringComparison.OrdinalIgnoreCase) && notice.EndsWith("is not registered", StringComparison.OrdinalIgnoreCase)); } return false; }
internal void HandleUserKicked(IrcUser user, string comment) { HandleUserKicked(this.users.Single(u => u.User == user), comment); }
/// <summary> /// Gets the user with the specified user name, creating it if necessary. /// </summary> /// <param name="userName">The user name of the user.</param> /// <param name="createdNew"><see langword="true"/> if the user object was created during the call; /// <see langword="false"/>, otherwise.</param> /// <returns>The user object that corresponds to the specified user name.</returns> protected IrcUser GetUserFromUserName(string userName, out bool createdNew) { if (userName == null) throw new ArgumentNullException("userName"); if (userName.Length == 0) throw new ArgumentException(Properties.Resources.MessageValueCannotBeEmptyString, "userName"); // Search for user with given nick name in list of known users. If it does not exist, add it. lock (((ICollection)this.usersReadOnly).SyncRoot) { var user = this.users.SingleOrDefault(u => u.UserName == userName); if (user == null) { user = new IrcUser(); user.Client = this; user.UserName = userName; this.users.Add(user); createdNew = true; } else { createdNew = false; } return user; } }
/// <summary> /// Gets the or create guest user. /// </summary> /// <param name="ircUser"> /// The irc user. /// </param> /// <returns> /// The <see cref="User"/>. /// </returns> private User GetOrCreateGuestUser(IrcUser ircUser) { if (this.cache.Contains(ircUser.NickName)) { Trace.TraceInformation("Returning {0} from cache", ircUser.NickName); return this.cache[ircUser.NickName] as User; } Trace.TraceInformation("Adding {0} to cache", ircUser.NickName); // todo: set back guest user access level. CacheItem item = new CacheItem(ircUser.NickName ?? ircUser.NickName, new User { AccessLevel = AccessLevel.Root, Host = ircUser.HostName, Nick = ircUser.NickName, Email = string.Empty, Id = Guid.Empty }); this.cache.Add(item, new CacheItemPolicy { Priority = CacheItemPriority.Default, SlidingExpiration = TimeSpan.FromMinutes(30), RemovedCallback = this.OnRemoved }); return this.cache[ircUser.NickName] as User; }
/// <inheritdoc/> /// <summary> /// Initializes a new instance of the <see cref="IrcUserEventArgs"/> class. /// </summary> /// <param name="user">The user that the event concerns.</param> public IrcUserEventArgs(IrcUser user, string comment = null) : base(comment) { if (user == null) throw new ArgumentNullException("user"); this.User = user; }
/// <summary> /// </summary> /// <param name="ircUser"> /// </param> public CellAoBotUser(IrcUser ircUser) { Debug.Assert(ircUser != null); this.IrcUser = ircUser; }
internal void HandleModesChanged(IrcUser source, string newModes, IEnumerable<string> newModeParameters) { lock (((ICollection)this.modesReadOnly).SyncRoot) this.modes.UpdateModes(newModes, newModeParameters, this.client.ChannelUserModes, (add, mode, modeParameter) => this.users.Single( cu => cu.User.NickName == modeParameter).HandleModeChanged(add, mode)); OnModesChanged(new IrcUserEventArgs(source)); }
protected virtual void OnChannelModeChanged(IrcChannel channel, IrcUser source, string newModes, IEnumerable<string> newModeParameters) { }
protected virtual void OnChannelModeChanged(IrcChannel channel, IrcUser source, string newModes, IEnumerable <string> newModeParameters) { }
internal void HandleUserKicked(IrcUser user, string comment) { lock (((ICollection)Modes).SyncRoot) HandleUserKicked(users.Single(u => u.User == user), comment); }
internal void HandleTopicChanged(IrcUser source, string newTopic) { Topic = newTopic; OnTopicChanged(new IrcUserEventArgs(source)); }
/// <inheritdoc /> /// <summary> /// Initializes a new instance of the <see cref="IrcUserEventArgs" /> class. /// </summary> /// <param name="user">The user that the event concerns, or <see langword="null" /> for no user.</param> public IrcUserEventArgs(IrcUser user, string comment = null) : base(comment) { User = user; }
/// <summary> /// Gets the <see cref="IrcChannelUser"/> in the channel that corresponds to the specified /// <see cref="IrcUser"/>, or <see langword="null"/> if none is found. /// </summary> /// <param name="user">The <see cref="IrcUser"/> for which to look.</param> /// <returns>The <see cref="IrcChannelUser"/> in the channel that corresponds to the specified /// <see cref="IrcUser"/>, or <see langword="null"/> if none is found.</returns> /// <exception cref="ArgumentNullException"><paramref name="user"/> is <see langword="null"/>.</exception> public IrcChannelUser GetChannelUser(IrcUser user) { if (user == null) throw new ArgumentNullException("user"); return this.users.SingleOrDefault(cu => cu.User == user); }
/// <inheritdoc/> /// <summary> /// Initializes a new instance of the <see cref="IrcUserEventArgs"/> class. /// </summary> /// <param name="user">The user that the event concerns, or <see langword="null"/> for no user.</param> public IrcUserEventArgs(IrcUser user, string comment = null) : base(comment) { this.User = user; }
internal void HandleUserInvited(IrcUser user) { lock (((ICollection)this.modesReadOnly).SyncRoot) OnUserInvited(new IrcUserEventArgs(user)); }
internal void HandleUserInvited(IrcUser user) { lock (this.modesReadOnly) OnUserInvited(new IrcUserEventArgs(user)); }
/// <summary> /// Gets the user with the specified nick name, creating it if necessary. /// </summary> /// <param name="nickName">The nick name of the user.</param> /// <param name="isOnline"> /// <see langword="true" /> if the user is currently online; /// <see langword="false" />, if the user is currently offline. /// The <see cref="IrcUser.IsOnline" /> property of the user object is set to this value. /// </param> /// <param name="createdNew"> /// <see langword="true" /> if the user object was created during the call; /// <see langword="false" />, otherwise. /// </param> /// <returns>The user object that corresponds to the specified nick name.</returns> protected IrcUser GetUserFromNickName(string nickName, bool isOnline, out bool createdNew) { if (nickName == null) throw new ArgumentNullException("nickName"); if (nickName.Length == 0) throw new ArgumentException(Resources.MessageValueCannotBeEmptyString, "nickName"); // Search for user with given nick name in list of known users. If it does not exist, add it. IrcUser user; lock (((ICollection) Users).SyncRoot) { user = users.SingleOrDefault(u => u.NickName == nickName); if (user == null) { user = new IrcUser { Client = this, NickName = nickName }; users.Add(user); createdNew = true; } else { createdNew = false; } } user.IsOnline = isOnline; return user; }
/// <inheritdoc cref="Invite(string)"/> /// <param name="user">The user to invite to the channel</param> public void Invite(IrcUser user) { Invite(user.NickName); }
// List of all currently logged-in Twitter users. // private List<CellAOUsers> cellAoUserses; private CellAoBotUser GetCellAOBotUser(IrcUser ircUSer) { CellAoBotUser CellAOUser = this.cellAoBotUsers.SingleOrDefault(tu => tu.IrcUser == ircUSer); if (CellAOUser == null) { throw new InvalidOperationException( string.Format("User '{0}' is not logged in to Cellao.", ircUSer.NickName)); } return CellAOUser; }
internal void HandleTopicChanged(IrcUser source, string newTopic) { this.Topic = newTopic; OnTopicChanged(new IrcUserEventArgs(source)); }
internal void HandleUserKicked(IrcUser user, string comment) { lock (((ICollection)this.modesReadOnly).SyncRoot) HandleUserKicked(this.users.Single(u => u.User == user), comment); }
internal void HandleUserLeft(IrcUser user, string comment) { lock (((ICollection)this.modesReadOnly).SyncRoot) HandleUserLeft(this.users.Single(u => u.User == user), comment); }
private void NotImplemented(IrcClient Client, string channel, IrcUser Sender, string message) { Client.LocalUser.SendMessage(channel, "Not implemented"); }
private TwitterBotUser GetTwitterBotUser(IrcUser ircUser) { var twitterUser = this.twitterUsers.SingleOrDefault(tu => tu.IrcUser == ircUser); if (twitterUser == null) throw new InvalidOperationException(string.Format( "User '{0}' is not logged in to Twitter.", ircUser.NickName)); return twitterUser; }