internal bool DeleteMessageCommand(TgMessage RawMessage) { if (TgApi.getDefaultApiConnection().checkIsAdmin(RawMessage.chat.id, RawMessage.from.id) || RAPI.getIsBotOP(RawMessage.GetSendUser().id) || RAPI.getIsBotAdmin(RawMessage.GetSendUser().id)) { TgApi.getDefaultApiConnection().deleteMessage(RawMessage.GetReplyMessage().chat.id, RawMessage.GetReplyMessage().message_id); return(true); } return(true); }
internal static bool GetIsInWhiteList(int id) { if (RAPI.getIsBotOP(id) || RAPI.getIsBotAdmin(id)) { return(true); } if (WhiteList.CheckInList(id)) { return(true); } return(false); }
internal bool Leave(TgMessage RawMessage) { int saySpace = RawMessage.text.IndexOf(" "); if (saySpace == -1) { if (RAPI.getIsBotAdmin(RawMessage.GetSendUser().id) || RAPI.getIsBotOP(RawMessage.GetSendUser().id) || TgApi.getDefaultApiConnection().checkIsAdmin(RawMessage.chat.id, RawMessage.GetSendUser().id)) { TgApi.getDefaultApiConnection().sendMessage(RawMessage.GetMessageChatInfo().id, "由 群管理 (" + RawMessage.GetSendUser().id + ") 請求離開群組", RawMessage.message_id); TgApi.getDefaultApiConnection().leaveChat(RawMessage.chat.id); return(true); } } if (TgApi.getDefaultApiConnection().checkIsAdmin(RawMessage.chat.id, RawMessage.GetSendUser().id)) { Dictionary <string, string> banValues = CommandDecoder.cutKeyIsValue(RawMessage.text.Substring(saySpace + 1)); long groupID = new GetValues().GetGroupID(banValues, RawMessage); if (groupID == 0) { TgApi.getDefaultApiConnection() .sendMessage(RawMessage.chat.id, "輸入錯誤!\n/leave [g=100000000]", RawMessage.message_id); } else { TgApi.getDefaultApiConnection().sendMessage(groupID, "由 Bot管理員 (" + RawMessage.GetSendUser().id + ") 請求離開群組", RawMessage.message_id); TgApi.getDefaultApiConnection().leaveChat(groupID); TgApi.getDefaultApiConnection().sendMessage(RawMessage.chat.id, "由 Bot管理員 (" + RawMessage.GetSendUser().id + ") 請求離開群組 " + groupID, RawMessage.message_id); } return(true); } TgApi.getDefaultApiConnection().sendMessage(RawMessage.GetMessageChatInfo().id, "您並不是群組管理或是 Bot 管理員", RawMessage.message_id); return(true); }
public string GetHelpMessage(TgMessage RawMessage, string MessageType) { string finalHelpMsg; string groupHelp = "/soamenable - 啟用功能\n" + "/soamdisable - 關閉功能\n" + "/soamstatus - 取得目前群組開啟功能\n"; string privateHelp = ""; string sharedHelp = "/twbanstat - 看看自己有沒有被封鎖\n" + "/lsop - Operator 名冊"; switch (RawMessage.chat.type) { case "group": case "supergroup": finalHelpMsg = groupHelp + "\n" + sharedHelp; break; case "private": finalHelpMsg = privateHelp + "\n" + sharedHelp; break; default: finalHelpMsg = sharedHelp; break; } if (RAPI.getIsBotOP(RawMessage.from.id)) { finalHelpMsg = finalHelpMsg + "\n\nOP指令:\n" + "/twban - 封鎖\n" + "/twunban - 解除封鎖\n" + "/getspampoints - 測試關鍵字\n\n" + "Admin指令:\n" + "/addspamstr - 新增 1 個自動規則\n" + "/delspamstr - 刪除 1 個自動規則\n" + "/getspamstr - 查看自動規則列表\n" + "/say - 廣播\n" + "/addop - 新增 Operator\n" + "/delop - 解除 Operator\n"; } return(finalHelpMsg); }
internal bool Leave(TgMessage RawMessage) { int saySpace = RawMessage.text.IndexOf(" "); if (saySpace == -1) { if (RAPI.getIsBotAdmin(RawMessage.GetSendUser().id) || RAPI.getIsBotOP(RawMessage.GetSendUser().id) || TgApi.getDefaultApiConnection().checkIsAdmin(RawMessage.chat.id, RawMessage.GetSendUser().id)) { TgApi.getDefaultApiConnection().sendMessage(RawMessage.GetMessageChatInfo().id, "由 群管理 (" + RawMessage.GetSendUser().id + ") 請求離開群組", RawMessage.message_id); TgApi.getDefaultApiConnection().leaveChat(RawMessage.chat.id); return(true); } } if (TgApi.getDefaultApiConnection().checkIsAdmin(RawMessage.chat.id, RawMessage.GetSendUser().id)) { long groupID = Convert.ToInt64(RawMessage.text.Substring(saySpace + 1).ToLower().Replace("g=", "")); if (groupID == 0) { TgApi.getDefaultApiConnection() .sendMessage(RawMessage.chat.id, "輸入錯誤!\n/leave [g=100000000]", RawMessage.message_id); } else { TgApi.getDefaultApiConnection().sendMessage(groupID, "由 Bot管理員 (" + RawMessage.GetSendUser().id + ") 請求離開群組", RawMessage.message_id); TgApi.getDefaultApiConnection().leaveChat(groupID); TgApi.getDefaultApiConnection().sendMessage(RawMessage.chat.id, "由 Bot管理員 (" + RawMessage.GetSendUser().id + ") 請求離開群組 " + groupID, RawMessage.message_id); } return(true); } TgApi.getDefaultApiConnection().sendMessage(RawMessage.GetMessageChatInfo().id, "您並不是群組管理或是 Bot 管理員", RawMessage.message_id); return(true); }
internal bool HelpStatus(TgMessage RawMessage) { string finalHelpMsg; string groupHelp = Strings.GROUP_HELP; string privateHelp = Strings.PRIVATE_HELP; string sharedHelp = Strings.SHARED_HELP; switch (RawMessage.chat.type) { case "group": case "supergroup": finalHelpMsg = groupHelp + "\n" + sharedHelp; break; case "private": finalHelpMsg = privateHelp + "\n" + sharedHelp; break; default: finalHelpMsg = sharedHelp; break; } if (RAPI.getIsBotOP(RawMessage.from.id) || RAPI.getIsBotAdmin(RawMessage.from.id)) { finalHelpMsg = finalHelpMsg + Strings.OPERATIOR_HELP; } if (RAPI.getIsBotAdmin(RawMessage.from.id)) { finalHelpMsg = finalHelpMsg + Strings.ADMIN_HELP; } finalHelpMsg = finalHelpMsg + Strings.HELP_AD; TgApi.getDefaultApiConnection() .sendMessage(RawMessage.GetMessageChatInfo().id, finalHelpMsg, RawMessage.message_id, ParseMode: TgApi.PARSEMODE_MARKDOWN); return(true); }
internal bool AdminCommands(TgMessage RawMessage, string JsonMessage, string Command) { if (RawMessage.GetReplyMessage() != null) { if (RawMessage.GetMessageChatInfo().id == Temp.InternGroupID && RawMessage.GetReplyMessage().GetSendUser().id == TgApi.getDefaultApiConnection().getMe().id) { switch (Command) { case "/devban": case "/ban": new BanUserCommand().Ban(RawMessage, JsonMessage, Command); throw new StopProcessException(); } } } if (RAPI.getIsBotOP(RawMessage.GetSendUser().id) || RAPI.getIsBotAdmin(RawMessage.GetSendUser().id)) { switch (Command) { case "/groups": new AllGroups().Groups_Status(RawMessage); throw new StopProcessException(); } if (!Temp.DisableBanList) { switch (Command) { case "/groupadmin": new GetAdmins().GetGroupAdmins(RawMessage); throw new StopProcessException(); case "/getspampoints": new SpamStringManager().GetSpamPoints(RawMessage); throw new StopProcessException(); case "/devban": case "/ban": new BanUserCommand().Ban(RawMessage, JsonMessage, Command); throw new StopProcessException(); case "/devunban": case "/unban": new UnbanUserCommand().Unban(RawMessage); throw new StopProcessException(); case "/addhk": new HKWhitelist().addHKWhitelist(RawMessage); throw new StopProcessException(); case "/delhk": new HKWhitelist().deleteHKWhitelist(RawMessage); throw new StopProcessException(); case "/lshk": new HKWhitelist().listHKWhitelist(RawMessage); throw new StopProcessException(); } } if (RAPI.getIsBotAdmin(RawMessage.GetSendUser().id)) { if (!Temp.DisableBanList) { switch (Command) { case "/getallspamstr": new SpamStringManager().GetAllInfo(RawMessage); return(true); case "/addspamstr": new SpamStringManager().Add(RawMessage); throw new StopProcessException(); case "/delspamstr": new SpamStringManager().Remove(RawMessage); throw new StopProcessException(); case "/suban": new BanMultiUserCommand().BanMulti(RawMessage, JsonMessage, Command); throw new StopProcessException(); case "/suunban": new UnBanMultiUserCommand().UnbanMulti(RawMessage); throw new StopProcessException(); case "/getspamstr": new SpamStringManager().GetName(RawMessage); throw new StopProcessException(); case "/reloadspamstr": new SpamStringManager().reloadSpamList(RawMessage); throw new StopProcessException(); } } switch (Command) { case "/points": new SpamStringManager().GetSpamKeywords(RawMessage); throw new StopProcessException(); case "/cleanup": new CleanUP().CleanUP_Status(RawMessage); throw new StopProcessException(); case "/say": new BroadCast().BroadCast_Status(RawMessage); throw new StopProcessException(); case "/sdall": new OP().SDAll(RawMessage); throw new StopProcessException(); case "/seall": new OP().SEAll(RawMessage); throw new StopProcessException(); case "/addop": new OP().addOP(RawMessage); throw new StopProcessException(); case "/delop": new OP().delOP(RawMessage); throw new StopProcessException(); case "/addwl": new Whitelist().addWhitelist(RawMessage); throw new StopProcessException(); case "/delwl": new Whitelist().deleteWhitelist(RawMessage); throw new StopProcessException(); case "/lswl": new Whitelist().listWhitelist(RawMessage); throw new StopProcessException(); case "/block": new BlockGroup().addBlockGroup(RawMessage); throw new StopProcessException(); case "/unblock": new BlockGroup().deleteBlockGroup(RawMessage); throw new StopProcessException(); case "/blocks": new BlockGroup().listBlockGroup(RawMessage); throw new StopProcessException(); } } } return(false); }
internal bool HelpStatus(TgMessage RawMessage) { string finalHelpMsg; string groupHelp = "/leave - 離開群組\n" + "/soamenable - 啟用功能\n" + "/soamdisable - 關閉功能\n" + "/soamstatus - 取得目前群組開啟功能"; string privateHelp = ""; string sharedHelp = "/banstat - 查詢處分狀態\n" + "/user - 取得 User ID\n" + "/lsop - Operator 名冊"; switch (RawMessage.chat.type) { case "group": case "supergroup": finalHelpMsg = groupHelp + "\n" + sharedHelp; break; case "private": finalHelpMsg = privateHelp + "\n" + sharedHelp; break; default: finalHelpMsg = sharedHelp; break; } if (RAPI.getIsBotOP(RawMessage.from.id) || RAPI.getIsBotAdmin(RawMessage.from.id)) { finalHelpMsg = finalHelpMsg + "\n\nOperator指令:\n" + "/groupadmin - 取得群組管理員名單\n" + "/cnban - 封鎖\n" + "/ban - 封鎖\n" + "/cnunban - 解除封鎖\n" + "/unban - 解除封鎖\n" + "/addhk - 新增使用者至HK白名單\n" + "/delhk - 從HK白名單中刪除使用者\n" + "/lshk - 取得HK白名單列表\n" + "/groups - 取得所有群組\n" + "/getspampoints - 測試關鍵字"; } if (RAPI.getIsBotAdmin(RawMessage.from.id)) { finalHelpMsg = finalHelpMsg + "\n\nAdmin指令:\n" + "/suban - 批次封鎖\n" + "/suunban - 批次解除封鎖\n" + "/addspamstr - 新增 1 個自動規則\n" + "/delspamstr - 刪除 1 個自動規則\n" + "/getspamstr - 查看自動規則列表\n" + "/getallspamstr - 查看所有自動規則列表\n" + "/reloadspamstr - 重新載入自動規則列表\n" + "/points - 取得匹配到的關鍵字\n" + "/say - 廣播\n" + "/addwl - 新增使用者至白名單\n" + "/delwl - 從白名單中刪除使用者\n" + "/lswl - 取得白名單列表\n" + "/block - 新增群組至禁止使用名單\n" + "/unblock - 從禁止使用名單中刪除群組\n" + "/blocks - 取得禁止使用名單\n" + "/addop - 新增 Operator\n" + "/delop - 解除 Operator\n" + "/seall - 開啟所有群組功能\n" + "/sdall - 關閉所有群組功能\n" + "/cleanup - 清理機器人不在群組內的群組資料\n"; } finalHelpMsg = finalHelpMsg + "\n如要贊助本項目請洽[生產公司](http://t.me/DonateDoramiBot)"; TgApi.getDefaultApiConnection() .sendMessage(RawMessage.GetMessageChatInfo().id, finalHelpMsg, RawMessage.message_id, ParseMode: TgApi.PARSEMODE_MARKDOWN); return(true); }
public CallbackMessage OnSupergroupCommandReceive(TgMessage RawMessage, string JsonMessage, string Command) { try { GroupCfg cfg = Temp.GetDatabaseManager().GetGroupConfig(RawMessage.chat.id); if (cfg.AdminOnly == 0) { if (TgApi.getDefaultApiConnection().checkIsAdmin(RawMessage.chat.id, RawMessage.from.id) || RAPI.getIsBotAdmin(RawMessage.from.id) || RAPI.getIsBotOP(RawMessage.from.id)) { } else { if (cfg.AutoDeleteCommand == 0) { new Thread(delegate() { SendMessageResult autodeletecommandsendresult = TgApi.getDefaultApiConnection() .sendMessage( RawMessage.GetMessageChatInfo().id, "請您不要亂玩機器人的指令,有問題請聯絡群組管理員。" ); Thread.Sleep(60000); TgApi.getDefaultApiConnection().deleteMessage( autodeletecommandsendresult.result.chat.id, autodeletecommandsendresult.result.message_id ); }).Start(); TgApi.getDefaultApiConnection().deleteMessage(RawMessage.chat.id, RawMessage.message_id); } return(new CallbackMessage { StopProcess = true }); } } if (SharedCommand(RawMessage, JsonMessage, Command)) { return(new CallbackMessage()); } switch (Command) { case "/leave": new LeaveCommand().Leave(RawMessage); break; case "/soamenable": new SoamManager().SoamEnable(RawMessage); break; case "/soamdisable": new SoamManager().SoamDisable(RawMessage); break; case "/__get_exception": throw new Exception(); case "/soamstat": case "/soamstatus": new SoamManager().SoamStatus(RawMessage); break; //case "/cnkick": // if (Temp.DisableBanList) // { // TgApi.getDefaultApiConnection().sendMessage( // RawMessage.chat.id, // "非常抱歉,目前版本已禁用封鎖用戶的功能,請聯絡管理員開啟此功能。", // RawMessage.message_id // ); // break; // } // if (RawMessage.reply_to_message == null) // { // TgApi.getDefaultApiConnection().sendMessage(RawMessage.chat.id, "請回覆一則訊息", RawMessage.message_id); // return new CallbackMessage(); // } // BanUser ban = Temp.GetDatabaseManager().GetUserBanStatus(RawMessage.reply_to_message.from.id); // if (ban.Ban == 0) // { // if (ban.Level == 0) // { // SetActionResult bkick_result = TgApi.getDefaultApiConnection().kickChatMember( // RawMessage.chat.id, // RawMessage.reply_to_message.from.id, // GetTime.GetUnixTime() + 86400 // ); // if (bkick_result.ok) // { // TgApi.getDefaultApiConnection().sendMessage(RawMessage.chat.id, "已移除", RawMessage.message_id); // return new CallbackMessage(); // } // else // { // TgApi.getDefaultApiConnection().sendMessage( // RawMessage.chat.id, // "無法移除,可能是機器人沒有適當的管理員權限。", // RawMessage.message_id // ); // return new CallbackMessage(); // } // } // else // { // TgApi.getDefaultApiConnection().sendMessage( // RawMessage.chat.id, // "無法移除,因為此使用者不在黑名單,請您聯絡群組的管理員處理。" + // "如果你認為這位使用者將會影響大量群組,您可連絡 @" + Temp.MainChannelName + " 提供的群組。", // RawMessage.message_id // ); // return new CallbackMessage(); // } // } // else // { // TgApi.getDefaultApiConnection().sendMessage( // RawMessage.chat.id, // "無法移除,因為此使用者不在黑名單,請您聯絡群組的管理員處理。" + // "如果你認為這位使用者將會影響大量群組,您可連絡 @" + Temp.MainChannelName + " 提供的群組。", // RawMessage.message_id // ); // return new CallbackMessage(); // } } return(new CallbackMessage()); } catch (StopProcessException) { return(new CallbackMessage { StopProcess = true }); } catch (Exception e) { RAPI.GetExceptionListener().OnException(e, JsonMessage); throw e; } }
internal bool AdminCommands(TgMessage RawMessage, string JsonMessage, string Command) { if (RAPI.getIsBotAdmin(RawMessage.GetSendUser().id) || RawMessage.GetMessageChatInfo().id == Config.InternGroupID) { if (!Config.DisableBanList) { switch (Command) { case "/history": if (Config.EnableBanHistory) { new GetHistory().getHistoryStatus(RawMessage); } throw new StopProcessException(); } } } if (RAPI.getIsBotOP(RawMessage.GetSendUser().id) || RAPI.getIsBotAdmin(RawMessage.GetSendUser().id) || RawMessage.GetMessageChatInfo().id == Config.InternGroupID) { switch (Command) { case "/groups": if (Config.EnableGetAllGroup) { new AllGroups().Groups_Status(RawMessage); } throw new StopProcessException(); } if (!Config.DisableBanList) { if (Command == "/" + Config.CustomPrefix + "ban") { if (Config.EnableCustomBan) { new BanUserCommand().Ban(RawMessage, JsonMessage, Command); } throw new StopProcessException(); } if (Command == "/" + Config.CustomPrefix + "unban") { if (Config.EnableCustomUnBan) { new UnbanUserCommand().Unban(RawMessage); } throw new StopProcessException(); } switch (Command) { case "/groupadmin": if (Config.EnableGetGroupAdmin) { new GetAdmins().GetGroupAdmins(RawMessage); } throw new StopProcessException(); case "/getspampoints": if (Config.EnableGetSpamStringPoints) { new SpamStringManager().GetSpamPoints(RawMessage); } throw new StopProcessException(); case "/ban": if (Config.EnableBan) { new BanUserCommand().Ban(RawMessage, JsonMessage, Command); } throw new StopProcessException(); case "/unban": if (Config.EnableUnBan) { new UnbanUserCommand().Unban(RawMessage); } throw new StopProcessException(); } } if (RAPI.getIsBotAdmin(RawMessage.GetSendUser().id)) { if (!Config.DisableBanList) { switch (Command) { case "/getallspamstr": if (Config.EnableGetAllSpamStringInfo) { new SpamStringManager().GetAllInfo(RawMessage); } return(true); case "/addspamstr": if (Config.EnableAddSpamString) { new SpamStringManager().Add(RawMessage); } throw new StopProcessException(); case "/delspamstr": if (Config.EnableDeleteSpamString) { new SpamStringManager().Remove(RawMessage); } throw new StopProcessException(); case "/suban": if (Config.EnableSuperBan) { new BanMultiUserCommand().BanMulti(RawMessage, JsonMessage, Command); } throw new StopProcessException(); case "/suunban": if (Config.EnableSuperUnBan) { new UnBanMultiUserCommand().UnbanMulti(RawMessage); } throw new StopProcessException(); case "/getspamstr": if (Config.EnableGetSpamString) { new SpamStringManager().GetName(RawMessage); } throw new StopProcessException(); case "/reloadspamstr": if (Config.EnableReloadSpamString) { new SpamStringManager().reloadSpamList(RawMessage); } throw new StopProcessException(); } } switch (Command) { case "/points": if (Config.EnableGetSpamStringKeywords) { new SpamStringManager().GetSpamKeywords(RawMessage); } throw new StopProcessException(); case "/cleanup": if (Config.EnableCleanUp) { new CleanUP().CleanUP_Status(RawMessage); } throw new StopProcessException(); case "/say": if (Config.EnableBroadcast) { new BroadCast().BroadCast_Status(RawMessage); } throw new StopProcessException(); case "/sdall": if (Config.EnableDisableAllGroupSoam) { new OP().SDAll(RawMessage); } throw new StopProcessException(); case "/seall": if (Config.EnableEnableAllGroupSoam) { new OP().SEAll(RawMessage); } throw new StopProcessException(); case "/addop": if (Config.EnableAddOP) { new OP().addOP(RawMessage); } throw new StopProcessException(); case "/delop": if (Config.EnableDeleteOP) { new OP().delOP(RawMessage); } throw new StopProcessException(); case "/addwl": if (Config.EnableWhitelistAdd) { new Whitelist().addWhitelist(RawMessage); } throw new StopProcessException(); case "/delwl": if (Config.EnableWhitelistDelete) { new Whitelist().deleteWhitelist(RawMessage); } throw new StopProcessException(); case "/lswl": if (Config.EnableWhitelisList) { new Whitelist().listWhitelist(RawMessage); } throw new StopProcessException(); case "/block": if (Config.EnableBlockListAdd) { new BlockGroup().addBlockGroup(RawMessage); } throw new StopProcessException(); case "/unblock": if (Config.EnableBlockListDelete) { new BlockGroup().deleteBlockGroup(RawMessage); } throw new StopProcessException(); case "/offspam": if (Config.EnableSpamOff) { new Spam().offSpam(RawMessage); } throw new StopProcessException(); case "/onspam": if (Config.EnableSpamOn) { new Spam().onSpam(RawMessage); } throw new StopProcessException(); case "/blocks": if (Config.EnableBlockListList) { new BlockGroup().listBlockGroup(RawMessage); } throw new StopProcessException(); } } } return(false); }