diff --git a/README.md b/README.md index 158905b..d771486 100644 --- a/README.md +++ b/README.md @@ -17,78 +17,156 @@ * **Arabic lock** * **And ...** +**Table of Contents** +- [TeleSeed](#teleseed) +- [Features](#features) +- [Commands](#commands) + - [Admins commands](#admins-commands) + - [Group creation](#group-creation) + - [Add or remove groups](#add-or-remove-groups) + - [Leaving](#leaving) + - [Everything about groups](#everything-about-groups) + - [Setting description in realm](#setting-description-in-realm) + - [Setting group name in realm](#setting-group-name-in-realm) + - [Setting rules in realm](#setting-rules-in-realm) + - [lock groups name|flood|photo|member in realm](#lock-groups-namefloodphotomember-in-realm) + - [Unlock groups name|flood|photo|member](#unlock-groups-namefloodphotomember) + - [Group setting in realm](#group-setting-in-realm) + - [Add admin](#add-admin) + - [Remove admin](#remove-admin) + - [Admins|group list in realm](#adminsgroup-list-in-realm) + - [Broadcast](#broadcast) + - [Global ban commands](#global-ban-commands) + - [Set group owner](#set-group-owner) + - [Bot stats](#bot-stats) + - [owners and mods commands](#owners-and-mods-commands) + - [Hammer](#hammer) + - [group name|member|arabic|flood|bots lock](#group-namememberarabicfloodbots-lock) + - [group name|member|arabic|flood|bots unlock](#group-namememberarabicfloodbots-unlock) + - [Group modlist|rules|about|member clean](#group-modlistrulesaboutmember-clean) + - [Set groups rules|about](#set-groups-rulesabout) + - [Setting or changing group owner](#setting-or-changing-group-photo) + - [Setting or changing group photo](#setting-or-changing-group-photo) + - [Changing group name](#changing-group-name) + - [Group link](#group-link) + - [Promote and demote mods](#promote-and-demote-mods) + - [Resolve username](#resolve-username) + - [Flood sensitivity](#flood-sensitivity) + - [Group rules and about](#group-rules-and-about) + - [Group settings](#group-settings) + - [modlist](#modlist) + - [Help](#help) + - [Owner](#owner) + - [Save and get](#save-and-get) + - [Id](#id) + - [Group stats](#group-stats) + - [Member list](#member-list) + - [In private commands](#in-private-commands) + - [Hammer](#hammer) + - [cleaning](#cleaning) + - [setting flood sensitivity](#setting-flood-sensitivity) + - [lock groups member|name](#lock-groups-membername) + - [unlock groups member|name](#unlock-groups-membername) + - [Group link](#group-link) + - [change name|rules|name](#change-namerulesname) + - [Group log](#group-log) + - [Join](#join) +- [Installation](#installation) + - [One command](#one-command) + - [Realm configuration](#realm-configuration) +- [Support and development](#support-and-development) +- [Special thanks to:](#special-thanks-to) +- [Our team!](#our-team-) # Commands ## Admins commands **Only admins and sudo users can run these commands** ### Group creation ->/creategroup [group name] +>[!/]creategroup [group name] > ->>/creategroup SEED +>>[!/]creategroup SEED >>>will create a group >>> >>>_Only works in realms But sudo users can use it everywhere_ +###Add or remove groups +>[!/]add +>>This command will add that group +> +>[!/]rem +>>This command will remove that group + +###Leaving +>[!/]leave +>>Bot will leave that group + +###Everything about groups +>[!/]all +>>This command will return everything about that group +> +>[!/]all [group_id] +>>_Only onwer,admin and sudo users can use this command + ### Setting description in realm -> /setabout [Group_id] [text] ->>/setabout 123456789 about ! +> [!/]setabout [Group_id] [text] +>>[!/]setabout 123456789 about >>>This command will set [text] as description of [Group_id] -### Setting Group name in realm -> /setname [Group_id] [text] ->>/setname 123456789 SEED +### Setting group name in realm +> [!/]setname [Group_id] [text] +>>[!/]setname 123456789 SEED >>>This command will set [text] as name of [Group_id] ### Setting rules in realm -> /setrules [Group_id] [text] ->>/setrules 123456789 rules ! +> [!/]setrules [Group_id] [text] +>>[!/]setrules 123456789 rules ! >>>This command will set [text] as rules of [Group_id] -### lock groups name|flood|photo|member in realm -> /lock [Group_id] [name|flood|photo|member] ->>/lock 123456789 name +### Lock groups name|flood|photo|member in realm +> [!/]lock [Group_id] [name|flood|photo|member] +>>[!/]lock 123456789 name >>>This command will lock name|flood|photo|member of [Group_id] ### Unlock groups name|flood|photo|member -> /Unlock [Group_id] [name|flood|photo|member] ->>/Unlock 123456789 name +> [!/]Unlock [Group_id] [name|flood|photo|member] +>>[!/]Unlock 123456789 name >>>This command will unlock name|flood|photo|member of [Group_id] ## Group setting in realm ->/setting [Group_id] ->>/setting 12345678 +>[!/]setting [Group_id] +>>[!/]setting 12345678 >>>This command will return settings of [Group_id] ### Add admin ->/addadmin [username] ->>/addadmin @username +>[!/]addadmin [username] +>>[!/]addadmin @username >>>This command will add username as admin >>> >>>_Only works in realms_ ### Remove admin ->/removeadmin [username] +>[!/]removeadmin [username] > ->!removeadmin [username] +>[!/]removeadmin [username] > ->>!removeadmin @username +>>[!/]removeadmin @username >>>This command will add username as admin >>> >>>_Only works in realms_ [username] ### Admins|group list in realm ->/list [admins|groups] ->>/list groups +>[!/]ist [admins|groups] +>>[!/]list groups >>>This command will return admins|groups list ### Broadcast ->/broadcast [text] ->>/broadcast Hello ! +>[!/]broadcast [text] +>>[!/]broadcast Hello ! >>>This command will send text to all groups >>> >>>_Only sudo users can run this command_ @@ -98,27 +176,27 @@ >>>This command will send text to [group_id] ##Global ban commands ->/banall [id] ->>/banall 123456789 +>[!/]banall [id] +>>[!/]banall 123456789 >>>This commands will globally ban [id] ->/unbanall [id] ->>/unbanall 123456789 +>[!/]unbanall [id] +>>[!/]unbanall 123456789 >>>This commands will remove [id] from global bans > ->/gbanlist +>[!/]gbanlist >>This command will return global bans ids > ->/banlist [group_id] ->>/banlist 123456789 +>[!/]banlist [group_id] +>>[!/]banlist 123456789 >>>This command will return banned user Of [group_id] ### Set group owner ->/setgpowner [group_id] [User_id] ->>/setgpowner 123456789 987654321 +>[!/]setgpowner [group_id] [User_id] +>>[!/]setgpowner 123456789 987654321 >>>This command will set [User_id] as the owner of [group_id] ### Bot stats ->/stats teleseed +>[!/]stats teleseed >>This command will return bot stats ## owners and mods commands @@ -127,139 +205,139 @@ _Sudo users and admins can also use this commands in all groups_ ### Hammer ->/kick [username|id] ->>/kick @useranme ->>/kick 123456789 +>[!/]kick [username|id] +>>[!/]kick @useranme +>>[!/]kick 123456789 >>>This command will remove that user > ->/ban [username|id] ->>/ban @username ->>/ban 123456789 +>[!/]ban [username|id] +>>[!/]ban @username +>>[!/]ban 123456789 >>>this command will ban and remove that user > ->/unban [id] ->>/unban 12345678 +>[!/]unban [id] +>>[!/]unban 12345678 >>>This command will unban that user > ->/banlist +>[!/]banlist >>This command will return bans list ### group name|member|arabic|flood|bots lock ->/lock [name|member|arabic|flood|bots] ->>/lock flood +>[!/]lock [name|member|arabic|flood|bots] +>>[!/]lock flood >>>This command will lock name|member|arabic|flood|bots of groups ### group name|member|arabic|flood|bots unlock ->/unlock [name|member|arabic|flood|bots] ->>/unlock flood +>[!/]unlock [name|member|arabic|flood|bots] +>>[!/]unlock flood >>>This command will unlock name|member|arabic|flood|bots of groups ### Group modlist|rules|about|member clean ->/clean [modlist|rules|about|member] ->>/clean modlist +>[!/]clean [modlist|rules|about|member] +>>[!/]clean modlist >>>This command will clean modlist|rules|about|member >>>_/clean member will kick all users except owner,admins and bot and it's for owners only_ ### Set groups rules|about ->/set [rules|about] [text] ->>/set rules don't spam ! +>[!/]set [rules|about] [text] +>>[!/]set rules don't spam! >> >>No NSFW >>> This command will set [text] as the rules|about of groups ### Setting or changing group owner ->/setowner [id] ->>/setowner 123456789 +>[!/]setowner [id] +>>[!/]setowner 123456789 >>>This command will set id as owner of that group ### Setting or changing group photo ->/setphoto +>[!/]setphoto >> This command will change or set group photo >>_also locks photo_ ### Changing Group name ->/setname [name] ->>/setname SEED +>[!/]setname [name] +>>[!/]setname SEED >>>This command will set [name] as name of groups ### Group link ->/newlink +>[!/]newlink >>This command will revoke group link > ->/link +>[!/]link >>This command will return group link ### Promote and demote mods ->/promote [username] ->>/promote @username +>[!/]promote [username] +>>[!/]promote @username >>>This command will promote @username as moderator > ->/demote [username] ->>/demote @username +>[!/]demote [username] +>>[!/]demote @username >>> This command will demote @username ### Resolve username ->/res [username] ->>/res @username +>[!/]res [username] +>>[!/]res @username >>>This command will return info about that username ### Flood sensitivity ->/setflood [value] ->>/set flood 15 +>[!/]setflood [value] +>>[!/]set flood 15 >>> will set flood sensitivity to [value] ### Group rules and about ->/about +>[!/]about >>This command will return group description > ->/rules +>[!/]rules >>This command will return group rules >>>_normal users can use it too_ ### Group settings ->/setting +>[!/]setting >>This command will return group settings ### modlist ->/modlist +>[!/]modlist >>This command will return group moderators >>>_normal users can use it too_ ###Help ->/help +>[!/]help ### Owner ->/owner +>[!/]owner >>This command will return owners id ### Save and get ->/save [title] [text] ->>/save spam Don't spam ! +>[!/]save [title] [text] +>>[!/]save spam Don't spam ! >>>This command will save text as that title > ->/get [title] ->>/get spam +>[!/]get [title] +>>[!/]get spam >>>This command will return text of that title ### Id ->/id +>[!/]id >>This command will return user or group id >>_can be triggered by reply_ >> >>_Normal users can use it_ ### group stats ->/stats +>[!/]stats >>This command will return group message statistic in a .txt file > ->/statslist +>[!/]statslist >>This command will return group message statistic ### member list ->/who +>[!/]who >>This command will return member list in a .txt file > ->/wholist +>[!/]wholist >>This command will return member list @@ -269,38 +347,38 @@ _Sudo users and admins can also use this commands in all groups_ **These commands only works in bots private** ### Hammer ->/owners group_id [kick|ban|unban] user_id ->>/owners 1234567 kick 1234567 +>[!/]owners group_id [kick|ban|unban] user_id +>>[!/]owners 1234567 kick 1234567 ### cleaning ->/owners group_id clean [modlist|rules|about] ->>/owners 1234567 clean modlist +>[!/]owners group_id clean [modlist|rules|about] +>>[!/]owners 1234567 clean modlist ### setting flood sensitivity ->/owners group_id setflood value ->>/owners 1234567 setflood 17 +>[!/]owners group_id setflood value +>>[!/]owners 1234567 setflood 17 ### lock groups member|name ->/owners group_id lock [member|name] ->>/owners 1234567 lock member +>[!/]owners group_id lock [member|name] +>>[!/]owners 1234567 lock member #### unlock groups member|name ->/owner group_id unlock [member|name] ->>/owners 1234567 unlock name +>[!/]owner group_id unlock [member|name] +>>[!/]owners 1234567 unlock name ### Group link ->/owners group_id get link ->>/owners 1234567 get link +>[!/]owners group_id get link +>>[!/]owners 1234567 get link > ->/owners group_id new link ->>/owners 1234567 new link +>[!/]owners group_id new link +>>[!/]owners 1234567 new link ### change name|rules|name ->/changename [group_id] [name] ->>/changename 123456789 SEED +>[!/]changename [group_id] [name] +>>[!/]changename 123456789 SEED > ->/changrules [group_id] [rules] ->>/changrules 123456789 rules ! +>[!/]changrules [group_id] [rules] +>>[!/]changrules 123456789 rules ! > >/changeabout [group_id] [about] >>/changeabout 123456789 about ! @@ -310,7 +388,7 @@ _Sudo users and admins can also use this commands in all groups_ >>/loggroup 123456789 ### Join ->/join [group_id] +>/[!/]oin [group_id] >> THis command will add user in [group_id] **U can use both "/" and "!"** @@ -358,7 +436,7 @@ then start the bot again Do not contact **us** In private for support. Join our bot development group by sending `/join 56670147` to [@TeleSeed](https://telegram.me/TeleSeed) -_If you are using /join service for first time you have to send it 11 time ( Bot is spam reported )_ +_If you are using /join service for first time you have to send it 11 times ( Bot is spam reported )_ # Special thanks to [@seyedan25](https://telegram.me/seyedan25) @@ -373,7 +451,7 @@ For graphic designs [@JuanPotato](https://github.com/JuanPotato) -# Our team ! +# Our team! [Alphonse](https://github.com/hmon) ([Telegram](https://telegram.me/iwals)) diff --git a/bot/seedbot.lua b/bot/seedbot.lua index 79985e5..0f05896 100644 --- a/bot/seedbot.lua +++ b/bot/seedbot.lua @@ -217,7 +217,8 @@ function create_config( ) "get", "broadcast", "download_media", - "invite" + "invite", + "all" }, sudo_users = {110626080,103649648,0,tonumber(our_id)},--Sudo users disabled_channels = {}, diff --git a/plugins/all.lua b/plugins/all.lua new file mode 100644 index 0000000..d90a6f5 --- /dev/null +++ b/plugins/all.lua @@ -0,0 +1,147 @@ +do +data = load_data(_config.moderation.data) +local function get_msgs_user_chat(user_id, chat_id) + local user_info = {} + local uhash = 'user:'..user_id + local user = redis:hgetall(uhash) + local um_hash = 'msgs:'..user_id..':'..chat_id + user_info.msgs = tonumber(redis:get(um_hash) or 0) + user_info.name = user_print_name(user)..' ['..user_id..']' + return user_info +end + +local function chat_stats(chat_id) + local hash = 'chat:'..chat_id..':users' + local users = redis:smembers(hash) + local users_info = {} + for i = 1, #users do + local user_id = users[i] + local user_info = get_msgs_user_chat(user_id, chat_id) + table.insert(users_info, user_info) + end + table.sort(users_info, function(a, b) + if a.msgs and b.msgs then + return a.msgs > b.msgs + end + end) + local text = 'chat stats! \n' + for k,user in pairs(users_info) do + text = text..user.name..' = '..user.msgs..'\n' + end + return text +end + +local function show_group_settings(target) + local data = load_data(_config.moderation.data) + if data[tostring(target)] then + if data[tostring(target)]['settings']['flood_msg_max'] then + NUM_MSG_MAX = tonumber(data[tostring(target)]['settings']['flood_msg_max']) + print('custom'..NUM_MSG_MAX) + else + NUM_MSG_MAX = 5 + end + end + local settings = data[tostring(target)]['settings'] + local text = "Lock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member.."\nflood sensitivity : "..NUM_MSG_MAX + return text +end + +local function get_description(target) + local data = load_data(_config.moderation.data) + local data_cat = 'description' + if not data[tostring(target)][data_cat] then + return 'No description available.' + end + local about = data[tostring(target)][data_cat] + return about +end + +local function get_rules(target) + local data = load_data(_config.moderation.data) + local data_cat = 'rules' + if not data[tostring(target)][data_cat] then + return 'No rules available.' + end + local rules = data[tostring(target)][data_cat] + return rules +end + +local function modlist(target) + local data = load_data(_config.moderation.data) + if not data[tostring(target)] then + return 'Group is not added.' + end + if next(data[tostring(target)]['moderators']) == nil then + return 'No moderator in this group.' + end + local i = 1 + local message = '\nList of moderators :\n' + for k,v in pairs(data[tostring(target)]['moderators']) do + message = message ..i..' - @'..v..' [' ..k.. '] \n' + i = i + 1 + end + return message +end + +local function get_link(target) + local data = load_data(_config.moderation.data) + local group_link = data[tostring(target)]['settings']['set_link'] + if not group_link then + return "No link" + end + return "Group link:\n"..group_link +end + +local function all(target, receiver) + local text = "All the things I know about this group \n \n" + local settings = show_group_settings(target) + text = text.."Group settings \n"..settings + local rules = get_rules(target) + text = text.."\n\nRules: \n"..rules + local description = get_description(target) + text = text.."\n\nAbout: \n"..description + local modlist = modlist(target) + text = text.."\n\n"..modlist + local link = get_link(target) + text = text.."\n\n"..link + local stats = chat_stats(target) + text = text.."\n\n"..stats + local ban_list = ban_list(target) + text = text.."\n\n"..ban_list + local file = io.open("./groups/"..target.."all.txt", "w") + file:write(text) + file:flush() + file:close() + send_document(receiver,"./groups/"..target.."all.txt", ok_cb, false) + return +end + +function run(msg, matches) + + if matches[1] == "all" and matches[2] and is_owner2(msg.from.id, matches[2]) then + local receiver = get_receiver(msg) + local target = matches[2] + return all(target, receiver) + end + if not is_owner(msg) then + return + end + if matches[1] == "all" and not matches[2] and msg.to.id ~= our_id then + local receiver = get_receiver(msg) + if not is_owner(msg) then + return + end + return all(msg.to.id, receiver) + end + + return +end + +return { + patterns = { + "^[!/](all)$", + "^[!/](all) (%d+)$" + }, + run = run +} +end \ No newline at end of file diff --git a/plugins/anti_spam.lua b/plugins/anti_spam.lua index 44a96b1..55a513d 100644 --- a/plugins/anti_spam.lua +++ b/plugins/anti_spam.lua @@ -15,15 +15,8 @@ local function pre_process(msg) if msg.from.id == our_id then return msg end - --Load moderation data - local data = load_data(_config.moderation.data) - if data[tostring(msg.to.id)] then - --Check if flood is one or off - if data[tostring(msg.to.id)]['settings']['flood'] == 'no' then - return msg - end - end - -- Save user on Redis + + -- Save user on Redis if msg.from.type == 'user' then local hash = 'user:'..msg.from.id print('Saving user', hash) @@ -51,6 +44,15 @@ local function pre_process(msg) local hash = 'msgs:'..msg.from.id..':'..msg.to.id redis:incr(hash) + --Load moderation data + local data = load_data(_config.moderation.data) + if data[tostring(msg.to.id)] then + --Check if flood is one or off + if data[tostring(msg.to.id)]['settings']['flood'] == 'no' then + return msg + end + end + -- Check flood if msg.from.type == 'user' then local hash = 'user:'..msg.from.id..':msgs' diff --git a/plugins/ingroup.lua b/plugins/ingroup.lua index fc277eb..e9ccd46 100644 --- a/plugins/ingroup.lua +++ b/plugins/ingroup.lua @@ -252,8 +252,6 @@ local function unlock_group_arabic(msg, data, target) end end - - local function lock_group_bots(msg, data, target) if not is_momod(msg) then return "For moderators only!" @@ -282,8 +280,6 @@ local function unlock_group_bots(msg, data, target) end end - - local function lock_group_namemod(msg, data, target) if not is_momod(msg) then return "For moderators only!" @@ -528,9 +524,11 @@ local function modlist(msg) if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way return 'No moderator in this group.' end + local i = 1 local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n' for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do - message = message .. '- @'..v..' [' ..k.. '] \n' + message = message ..i..' - @'..v..' [' ..k.. '] \n' + i = i + 1 end return message end @@ -629,21 +627,6 @@ local function run(msg, matches) return nil end end - if matches[1] == 'chat_add_user' then - if not msg.service then - return "Are you trying to troll me?" - end - local receiver = 'user#id'..msg.action.user.id - local data_cat = 'rules' - if not data[tostring(msg.to.id)][data_cat] then - return false - end - local rules = data[tostring(msg.to.id)][data_cat] - -- local rules = 'Welcome to "' .. string.gsub(msg.to.print_name, '_', ' ') ..'" this group has rules that you should follow:\n'..rules - - savelog(msg.to.id, name_log.." ["..msg.from.id.."] deleted user "..msg.action.user.id) - send_large_msg(receiver, rules) - end if matches[1] == 'chat_del_user' then if not msg.service then -- return "Are you trying to troll me?" diff --git a/plugins/inrealm.lua b/plugins/inrealm.lua index cc65179..49d6dc3 100644 --- a/plugins/inrealm.lua +++ b/plugins/inrealm.lua @@ -513,7 +513,7 @@ return { "^[!/](createrealm) (.*)$", "^[!/](setabout) (%d+) (.*)$", "^[!/](setrules) (%d+) (.*)$", - "^[!/](setgpname) (%d+) (.*)$", + "^[!/](setname) (%d+) (.*)$", "^[!/](lock) (%d+) (.*)$", "^[!/](unlock) (%d+) (.*)$", "^[!/](setting) (%d+)$",