Advertisement
Buzzrz

Test

Jan 24th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. --plugin made by @haam00dy and @thisisarman
  2. do
  3.  
  4. local function create_group_fromvip(msg)
  5. -- superuser and vip only (because sudo are always has privilege
  6. if is_vgroup(msg) then
  7. local group_creator = msg.from.print_name
  8. create_group_chat (group_creator, group_name, ok_cb, false)
  9. return 'Group [ '..string.gsub(group_name, '_', ' ')..' ] has been created.'
  10. end
  11. end
  12.  
  13. local function vip_list(msg)
  14. local data = load_data(_config.moderation.data)
  15. local admins = 'vip'
  16. if not data[tostring(admins)] then
  17. data[tostring(admins)] = {}
  18. save_data(_config.moderation.data, data)
  19. end
  20. local message = "List for bot's VIP:\n"
  21. for k,v in pairs(data[tostring(admins)]) do
  22. message = message .. '- @' .. v .. ' [' .. k .. '] ' ..'\n'
  23. end
  24. return message
  25. end
  26.  
  27. local function vip_help()
  28. local help_text = tostring(_config.vip_help)
  29. return help_text
  30. end
  31.  
  32. local function action_by_reply(extra, success, result)
  33. local msg = result
  34. local chat = msg.to.id
  35. local user_id = msg.from.id
  36. local receiver = extra.receiver
  37. local create_hash = 'creator:'..msg.from.id
  38. if msg.to.type == 'chat' then
  39. if extra.match == 'charge' then
  40. redis:set(create_hash, 0)
  41. send_large_msg(receiver, 'charged!!!')
  42. end
  43. else
  44. return 'In groups only'
  45. end
  46. end
  47.  
  48. local function run(msg, matches)
  49. local user_id = msg.from.id
  50. local create_hash = 'creator:'..user_id
  51. local is_create_offender = redis:get(create_hash)
  52. if msg.to.type == 'chat' and is_vgroup(msg) then
  53. if is_vip(msg) then
  54. if matches[1] == 'list' and matches[2] == 'vips' then
  55. return vip_list(msg)
  56. end
  57. if matches[1] == 'chat_add_user' then--if user added to vip group
  58. if not msg.service then
  59. return "Are you trying to troll me?"
  60. end
  61. local user = 'user#id'..msg.action.user.id
  62. local chat = 'chat#id'..msg.to.id
  63. if not is_vip(msg) then
  64. chat_del_user(chat, user, ok_cb, true)
  65. end
  66. end
  67. if matches[1] == 'help' and is_vgroup(msg) then
  68. return vip_help()
  69. end
  70. if matches[1] == 'creategroup' and matches[2] then
  71. redis:incr(create_hash)
  72. if is_create_offender then
  73. if tonumber(create_hash) == 2 then
  74. send_large_msg('chat#id'..msg.to.id, 'Group creation limit reached pls contact sudo for more credit')
  75. end
  76. redis:incr(create_hash)
  77. group_name = matches[2]
  78. group_type = 'group'
  79. return create_group_fromvip(msg)
  80. end
  81. end
  82. if matches[1] == 'charge' then
  83. if type(msg.reply_id) ~= 'nil' then
  84. msgr = get_message(msg.reply_id, action_by_reply, {match=matches[1],receiver=get_receiver(msg)})
  85. end
  86. end
  87. end
  88. end
  89. end
  90.  
  91. return {
  92. patterns = {
  93. "^[!/#]vip ([Cc]reategroup) (.*)$",
  94. "^[!/#]([Ll]ist) (vips)$",
  95. "^[!/#]([Hh]elp)$",
  96. "^[!/#]([Cc]harge)$",
  97. "^!!tgservice (.+)$",
  98. },
  99. run = run
  100. }
  101. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement