-
Notifications
You must be signed in to change notification settings - Fork 7
/
bot.lua
196 lines (177 loc) · 7.31 KB
/
bot.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
function dl_cb()
-- @sin_chi BY:SinaXhpm
end
serpent = require("serpent")redis = require('redis')db = redis.connect('127.0.0.1', 6379)
function vardump(value) print(serpent.block(value, {comment=false})) end
function process_chn(extra, tb)
print(vardump(tb))
if tb.code == 429 then
db:setex("IDchkl", 40, true)
else
db:srem("IDyess",extra.link)
db:sadd("IDestefade",extra.link)
end
end
function checklinks(i, tb)
print(vardump(tb))
if (tb.is_group or tb.is_supergroup_channel) then
db:srem("IDwaits", i.link)
db:sadd("IDyess", i.link)
db:setex("IDchkt", 70, true)
elseif tb.code == 429 then
local message = tostring(tb.message_)
local oime = tonumber(message:match('%d+')) + 50
db:setex("IDchkt", oime, true)
elseif tb.code == 3 then
db:setex("IDchkt", 45, true)
else
db:srem("IDwaits", i.link)
end
end
function tdbot_update_callback (data)
-- print("------ ------------------------- @Sin_Chi ------------------------------------- ')
if data and data._ == "updateNewMessage" then
function sendmessage(chat,text)
tdbot_function ({_="sendMessage", chat_id=chat, reply_to_message_id=0, disable_notification=false, from_background=true, reply_markup=nil, input_message_content={_="inputMessageText", text=text, disable_web_page_preview=true, clear_draft=false, entities={}, parse_mode=nil}}, dl_cb, nil)
end
local msg = data.message
if tostring(data.message.chat_id):match('-') and not db:sismember("gpsID",data.message.chat_id) then
print('---------------'..data.message.chat_id)
db:sadd("gpsID",data.message.chat_id)
end
if msg.content._ == "messageText" then
text= msg.content.text
if (msg.sender_user_id == 777000 or msg.sender_user_id == 178220800) then
local c = (msg.content_.text_):gsub("[0123456789", {["0"] = "0️⃣", ["1"] = "1️⃣", ["2"] = "2️⃣", ["3"] = "3️⃣", ["4"] = "4️⃣", ["5"] = "5️⃣", ["6"] = "6️⃣", ["7"] = "7️⃣", ["8"] = "8️⃣", ["9"] = "9️⃣", [":"] = ":--"})
for k,v in ipairs(sudo) do
sendmessage(v,c)
end
end
if text:match("https://telegram.me/joinchat/%S+") or text:match("https://t.me/joinchat/%S+") or text:match("https://telegram.dog/joinchat/%S+") then
local text = text:gsub("t.me", "telegram.me")
local text = text:gsub("telegram.dog", "telegram.me")
for link in text:gmatch("(https://telegram.me/joinchat/%S+)") do
if not db:sismember("1all", link) then
db:sadd("IDwaits", link)
db:sadd("IDall", link)
end
end
end
if not db:get("IDchkt") then
if db:scard("IDwaits") ~= 0 then
local links = db:smembers("IDwaits")
for x,y in ipairs(links) do
tdbot_function({_ = "checkChatInviteLink",invite_link = y},checklinks, {link=y})
if x == 1 then db:setex("IDchkt",13, true) return end
end
end
end
if not db:get("IDchkl") then
if db:scard("IDyess") ~= 0 then
local links = db:smembers("IDyess")
for x,y in ipairs(links) do
tdbot_function({_ = "importChatInviteLink",invite_link = y},process_chn, {link=y})
if x == 2 then db:setex("IDchkl", 30, true) return end
end
end
end
function is_sudo(msg)
sudos = dofile('sudo.lua')
local var = false
for v,user in pairs(sudo) do
if user == msg.sender_user_id or db:sismember('mods1',msg.sender_user_id) then var = true end
end
return var
end
if msg.chat_id == db:get("IDidchannel") then
local list = db:smembers("gpsID")
local list1 = db:scard('gpsID')
for k,v in pairs(list) do
tdbot_function({_ = "forwardMessages",chat_id =""..v,from_chat_id = msg.chat_id,message_ids = {[0] = tonumber(msg.id)},disable_notification = true,from_background = true}, dl_cb, nil)
end
end
if is_sudo(msg) then
if text == 'bc' and tonumber(msg.reply_to_message_id) > 0 then
function ok(a,b,c)
local list = db:smembers("gpsID")
local list1 = db:scard('gpsID')
for k,v in pairs(list) do
tdbot_function({_ = "forwardMessages",chat_id =""..v,from_chat_id = msg.chat_id,message_ids = {[0] = tonumber(b.id)},disable_notification = true,from_background = true}, dl_cb, nil)
end
sendmessage(msg.chat_id,"Done \n action(Forward)♻️")
end
tdbot_function({
_ = "getMessage",
chat_id = msg.chat_id,
message_id = msg.reply_to_message_id
}, ok,nil)
elseif text=="leftall" then
function chk(e,info)
local list = db:smembers("gpsID")
for i, v in pairs(list) do
db:srem("gpsID",v)
tdbot_function ({
_ = "changeChatMemberStatus",
chat_id = v,
user_id = info.id,
status = {_ = "chatMemberStatusLeft"},
}, dl_cb, nil)
end
sendmessage(msg.chat_id,"Done \n action(Left)✅")
end
tdbot_function ({_ = "getMe",}, chk, nil)
elseif text=="refresh" then
db:del("gpsID")
sendmessage(msg.chat_id,"Done \n action(Reload Stats)✅")
elseif text:match("^(join) (.*)$") then
local matches = text:match("^join (.*)$")
function joinchannel(extra, tb)
print(vardump(tb))
if tb._ == "ok" then
sendmessage(msg.chat_id,"Done \n action(Join)✅")
else
sendmessage(msg.chat_id,"failure !! \n action(Join)✅")
end
end
tdbot_function({_ = "importChatInviteLink",invite_link = matches},joinchannel, nil)
elseif text:match("^(add) (.*)$") then
local matches = text:match("^add (.*)$")
assert (tdbot_function ({
_ = 'importContacts',
contacts = {
[0] = {
_ = 'contact',
phone_number = tostring(matches),
first_name = tostring("tor "),
last_name = tostring("tobo"),
user_id = 0
}
},
}, dl_cb,nil))
sendmessage(msg.chat_id,"Done \n action(Add Contact "..matches..")📙")
elseif text:match("^(addall) (.*)$") then
local matches = text:match("^addall (.*)$")
local list = db:smembers("gpsID")
for i, v in pairs(list) do
assert (tdbot_function ({
_ = 'addChatMember',
chat_id = v,
user_id = matches,
forward_limit = 50
}, dl_cb, nil))
end
sendmessage(msg.chat_id,"Done \n action(AddAll "..matches..")👥")
elseif text:match("^(set) (.*)$") then
local matches = text:match("^set (.*)$")
db:set("IDidchannel",matches)
sendmessage(msg.chat_id,"Done \n action(Set channel id to "..matches..")🔑")
elseif text=="help" then
sendmessage(msg.chat_id,"https://t.me/Sin_Chi/766")
elseif text=="panel" then
sendmessage(msg.chat_id,"SuperGps :"..(db:scard("gpsID") or 0).."\n Channel:"..(db:get("IDidchannel") or 0).."\n UsedLinks : "..(db:scard("IDestefade") or 0))
end
-- @sin_chi BY:SinaXhpm
end
end
end
end