コード例 #1
0
 /// <summary>
 ///     Constuctor for class of arguments for event, which invoked when command ready to invoke (ARGH)
 /// </summary>
 /// <param name="command">Command</param>
 /// <param name="message">Message</param>
 public BeginInvokeEventArgs(ICommand command, Message message)
 {
     Command = command;
     Message = message;
     Refuse = false;
     RunSync = false;
 }
コード例 #2
0
ファイル: Update.cs プロジェクト: alim1369/TeleBot.NET
		/// <summary>
		///	 Update constructor
		/// </summary>
		/// <param name="updateId">
		///	 The update‘s unique identifier. Update identifiers start from a certain positive number and
		///	 increase sequentially. This ID becomes especially handy if you’re using Webhooks, since it allows you to ignore
		///	 repeated updates or to restore the correct update sequence, should they get out of order.
		/// </param>
		/// <param name="message">New incoming message of any kind — text, photo, sticker, etc.</param>
		public Update(long updateId, Message message)
		{
			Id = updateId;
			Message = message;
		}
コード例 #3
0
ファイル: Bot.cs プロジェクト: Nummer/Telesharp
		private void ExecuteSync(ICommand command, Message message)
		{
			try
			{
				// Execute command
				command.Executed(message);
			}
			catch (Exception exc)
			{
				if (Settings.ExceptionsToConsole)
					Telesharp.Logger.Log(LogType.Error, Settings.Name, $"Exception, when execute command:\n{exc}");
			}
		}
コード例 #4
0
ファイル: Bot.cs プロジェクト: Nummer/Telesharp
		private void Execute(ICommand command, Message message)
		{
			if (Settings.MaximumThreadsForCommands > 0 && _threads >= Settings.MaximumThreadsForCommands)
			{
				while (_threads <= Settings.MaximumThreadsForCommands)
				{
					// Wait, when we can go to execute command
				}
			}
			Task.Factory.StartNew(() =>
			{
				try
				{
					_threads++;
					command.Executed(message);
				}
				catch (Exception exc)
				{
					if (Settings.ExceptionsToConsole)
						Telesharp.Logger.Log(LogType.Error, Settings.Name, $"Exception, when execute command:\n{exc}");
				}
				finally
				{
					_threads--;
				}
			});
		}
コード例 #5
0
ファイル: Bot.cs プロジェクト: Nummer/Telesharp
		private ICommand FindCommand(Message message)
		{
			return Commands.FirstOrDefault(command => Comparer.Compare(command, message));
		}
コード例 #6
0
 /// <summary>
 ///     ParseMessageEventArgs constructor
 /// </summary>
 /// <param name="message"></param>
 public ParseMessageEventArgs(Message message)
 {
     Message = message;
 }
コード例 #7
0
 /// <summary>
 ///     <see cref="ICommand.Executed" />
 /// </summary>
 /// <param name="message"></param>
 public virtual void Executed(Message message)
 {
     throw new NotImplementedException();
 }
コード例 #8
0
 /// <summary>
 ///     Command consturctor
 /// </summary>
 /// <param name="prototype">Prototype</param>
 /// <param name="helpText">Helpful text</param>
 /// <param name="compareMode">Compare mode</param>
 public SimpleComparerCommand(Message prototype, string helpText = null, Mode compareMode = Mode.IsSame)
 {
     Prototype = prototype;
     CompareMode = compareMode;
     HelpText = helpText;
 }
コード例 #9
0
 /// <summary>
 ///     Invoked for compare command
 /// </summary>
 /// <param name="command">Command</param>
 /// <param name="message">Message</param>
 /// <returns></returns>
 public virtual bool Compare(ICommand command, Message message)
 {
     return message.Text != null && command.Prototype.Text == message.Text;
 }