Skip to content

Commit

Permalink
Revert "Updates For Testing pt. 2"
Browse files Browse the repository at this point in the history
  • Loading branch information
Rondoozle committed Dec 15, 2015
1 parent 5667772 commit 0a400ea
Show file tree
Hide file tree
Showing 12 changed files with 136 additions and 440 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ luac.out
*.lo
*.def
*.exp
*.luarocks

# Shared objects (inc. Windows DLLs)
*.dll
Expand Down
42 changes: 0 additions & 42 deletions .gitignore~

This file was deleted.

50 changes: 46 additions & 4 deletions bot/seedbot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -226,87 +226,129 @@ function create_config( )
moderation = {data = 'data/moderation.json'},
about_text = [[Teleseed v1
An advance Administration bot based on yagop/telegram-bot
https://github.com/SEEDTEAM/TeleSeed
Admins
@iwals [Founder]
@imandaneshi [Developer]
@seyedan25 [Manager]
Special thanks to
awkward_potato
Siyanew
topkecleon
Vamptacus
Our channels
@teleseedch [English]
]],
help_text = [[
Commands list :
!kick [username|id]
You can also do it by reply
!ban [ username|id]
You can also do it by reply
!unban [id]
You can also do it by reply
!who
Members list
!modlist
Moderators list
!promote [username]
Promote someone
!demote [username]
Demote someone
!kickme
Will kick user
!about
Group description
!setphoto
Set and locks group photo
!setname [name]
Set group name
!rules
Group rules
!id
return group id or user id
!help
!lock [member|name]
Locks [member|name]
!unlock [member|name|photo]
Unlocks [member|name|photo]
!lock [member|name|bots]
Locks [member|name|bots]
!unlock [member|name|photo|bots]
Unlocks [member|name|photo|bots]
!set rules <text>
Set <text> as rules
!set about <text>
Set <text> as about
!settings
Returns group settings
!newlink
create/revoke your group link
!link
returns group link
!owner
returns group owner id
!setowner [id]
Will set id as owner
!setflood [value]
Set [value] as flood sensitivity
!stats
Simple message statistics
!save [value] <text>
Save <text> as [value]
!get [value]
Returns text of [value]
!clean [modlist|rules|about]
Will clear [modlist|rules|about] and set it to nil
!res [username]
returns user id
"!res @username"
!log
will return group logs
!banlist
will return group ban list
**U can use both "/" and "!"
*Only owner and mods can add bots in group
*Only moderators and owner can use kick,ban,unban,newlink,link,setphoto,setname,lock,unlock,set rules,set about and settings commands
*Only owner can use res,setowner,promote,demote and log commands
]]

}
Expand Down
50 changes: 14 additions & 36 deletions bot/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -533,30 +533,14 @@ end
--Check if this chat is realm or not
function is_realm(msg)
local var = false
local realms = 'realms'
local data = load_data(_config.moderation.data)
local chat = msg.to.id
if data[tostring(realms)] then
if data[tostring(realms)][tostring(msg.to.id)] then
var = true
end
return var
for v,group in pairs(_config.realm) do
if group == msg.to.id then
var = true
end
end
return var
end

--Check if this chat is a group or not
function is_group(msg)
local var = false
local groups = 'groups'
local data = load_data(_config.moderation.data)
local chat = msg.to.id
if data[tostring(groups)] then
if data[tostring(groups)][tostring(msg.to.id)] then
var = true
end
return var
end
end

function savelog(group, logtxt)

Expand Down Expand Up @@ -587,7 +571,8 @@ end
function is_owner(msg)
local var = false
local data = load_data(_config.moderation.data)
local user = msg.from.id
local user = msg.from.id

if data[tostring(msg.to.id)] then
if data[tostring(msg.to.id)]['set_owner'] then
if data[tostring(msg.to.id)]['set_owner'] == tostring(user) then
Expand All @@ -612,6 +597,7 @@ end
function is_owner2(user_id, group_id)
local var = false
local data = load_data(_config.moderation.data)

if data[tostring(group_id)] then
if data[tostring(group_id)]['set_owner'] then
if data[tostring(group_id)]['set_owner'] == tostring(user_id) then
Expand All @@ -637,7 +623,6 @@ end
function is_admin(msg)
local var = false
local data = load_data(_config.moderation.data)
local data = load_data(_config.moderation.data)
local user = msg.from.id
local admins = 'admins'
if data[tostring(admins)] then
Expand All @@ -656,7 +641,6 @@ end
function is_admin2(user_id)
local var = false
local data = load_data(_config.moderation.data)
local data = load_data(_config.moderation.data)
local user = user_id
local admins = 'admins'
if data[tostring(admins)] then
Expand Down Expand Up @@ -755,12 +739,6 @@ function kick_user(user_id, chat_id)
chat_del_user(chat, user, ok_cb, true)
end

function kick_user_any(user_id, chat_id)
local chat = 'chat#id'..chat_id
local user = 'user#id'..user_id
chat_del_user(chat, user, ok_cb, true)
end

-- Ban
function ban_user(user_id, chat_id)
if tonumber(user_id) == tonumber(our_id) then -- Ignore bot
Expand Down Expand Up @@ -814,7 +792,7 @@ end
function ban_list(chat_id)
local hash = 'banned:'..chat_id
local list = redis:smembers(hash)
local text = "Ban list!\n\n"
local text = "Ban list !\n\n"
for k,v in pairs(list) do
text = text..k.." - "..v.." \n"
end
Expand Down Expand Up @@ -846,7 +824,7 @@ end
function Kick_by_reply(extra, success, result)
if result.to.type == 'chat' then
local chat = 'chat#id'..result.to.id
if tonumber(result.from.id) == tonumber(our_id) and not is_sudo(msg) then -- Ignore bot
if tonumber(result.from.id) == tonumber(our_id) then -- Ignore bot
return "I won't kick myself"
end
if is_momod2(result.from.id, result.to.id) then -- Ignore mods,owner,admin
Expand All @@ -870,7 +848,7 @@ function Kick_by_reply_admins(extra, success, result)
end
chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false)
else
return 'Error: I cannont kick this user.'
return 'Use This in Your Groups'
end
end

Expand Down Expand Up @@ -920,7 +898,7 @@ function unban_by_reply(extra, success, result)
local hash = 'banned:'..result.to.id
redis:srem(hash, result.from.id)
else
return 'Use this in Your Groups'
return 'Use This in Your Groups'
end
end
function banall_by_reply(extra, success, result)
Expand All @@ -937,6 +915,6 @@ function banall_by_reply(extra, success, result)
chat_del_user(chat, 'user#id'..result.from.id, ok_cb, false)
send_large_msg(chat, "User "..name.."["..result.from.id.."] hammered")
else
return 'Use this in Your Groups'
return 'Use This in Your Groups'
end
end
end
2 changes: 1 addition & 1 deletion launch.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@ else
fi

./tg/bin/telegram-cli -k ./tg/tg-server.pub -s ./bot/seedbot.lua -l 1 -E $@
fi
fi
18 changes: 10 additions & 8 deletions plugins/banhammer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,24 @@ local function pre_process(msg)
kick_user(msg.from.id, msg.to.id)-- Kick user who adds ban ppl more than 3 times
end
if tonumber(banaddredis) == 8 and not is_owner(msg) then
ban_user(msg.from.id, msg.to.id)-- ban user who adds ban ppl more than 7 times
ban_user(msg.from.id, msg.to.id)-- Kick user who adds ban ppl more than 7 times
local banhash = 'addedbanuser:'..msg.to.id..':'..msg.from.id
redis:set(banhash, 0)-- Reset the Counter
end
end
end
--[[ local bots_protection = "yes"
local bots_protection = "Yes"
local data = load_data(_config.moderation.data)
if not data[tostring(msg.to.id)]['settings']['lock_bots'] then
bots_protection = data[tostring(msg.to.id)]['settings']['lock_bots']
end]]
if msg.action.user.flags == 4352 and not is_momod(msg) and bots_protection == "yes" then --- Will kick bots added by normal users
if data[tostring(msg.to.id)]['settings']['lock_bots'] then
bots_protection = data[tostring(msg.to.id)]['settings']['lock_bots']
end
if msg.action.user.username ~= nil then
if string.sub(msg.action.user.username:lower(), -3) == 'bot' and not is_momod(msg) and bots_protection == "yes" then --- Will kick bots added by normal users
local name = user_print_name(msg.from)
savelog(msg.to.id, name.." ["..msg.from.id.."] added a bot > @".. msg.action.user.username)-- Save to logs
kick_user(msg.action.user.id, msg.to.id)
end
end
end
-- No further checks
return msg
Expand Down Expand Up @@ -219,8 +221,8 @@ local function run(msg, matches)
local user_id = matches[2]
local chat_id = msg.to.id
if string.match(matches[2], '^%d+$') then
if tonumber(result.from.id) == tonumber(our_id) and not is_sudo(msg) then -- Ignore bot
return "I won't kick myself"
if tonumber(matches[2]) == tonumber(our_id) then
return
end
if not is_admin(msg) and is_momod2(matches[2], msg.to.id) then
return "you can't kick mods/owner/admins"
Expand Down
Loading

0 comments on commit 0a400ea

Please sign in to comment.