/
api_setter.py
96 lines (86 loc) · 2.9 KB
/
api_setter.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
# Ultroid - UserBot
# Copyright (C) 2021 TeamUltroid
#
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
from . import *
# main menu for api setting
@callback("apiset")
@owner
async def apiset(event):
await event.edit(
get_string("ast_1"),
buttons=[
[Button.inline("Remove.bg API", data="rmbg")],
[Button.inline("DEEP API", data="dapi")],
[Button.inline("OCR API", data="oapi")],
[Button.inline("« Back", data="setter")],
],
)
@callback("rmbg")
@owner
async def rmbgapi(event):
await event.delete()
pru = event.sender_id
var = "RMBG_API"
name = "Remove.bg API Key"
async with event.client.conversation(pru) as conv:
await conv.send_message(get_string("ast_2"))
response = conv.wait_event(events.NewMessage(chats=pru))
response = await response
themssg = response.message.message
if themssg == "/cancel":
return await conv.send_message(
"Cancelled!!",
buttons=get_back_button("apiset"),
)
await setit(event, var, themssg)
await conv.send_message(
f"{name} changed to {themssg}",
buttons=get_back_button("apiset"),
)
@callback("dapi")
@owner
async def rmbgapi(event):
await event.delete()
pru = event.sender_id
var = "DEEP_API"
name = "DEEP AI API Key"
async with event.client.conversation(pru) as conv:
await conv.send_message("Get Your Deep Api from deepai.org and send here.")
response = conv.wait_event(events.NewMessage(chats=pru))
response = await response
themssg = response.message.message
if themssg == "/cancel":
return await conv.send_message(
"Cancelled!!",
buttons=get_back_button("apiset"),
)
await setit(event, var, themssg)
await conv.send_message(
f"{name} changed to {themssg}",
buttons=get_back_button("apiset"),
)
@callback("oapi")
@owner
async def rmbgapi(event):
await event.delete()
pru = event.sender_id
var = "OCR_API"
name = "OCR API Key"
async with event.client.conversation(pru) as conv:
await conv.send_message("Get Your OCR api from ocr.space Send Send Here.")
response = conv.wait_event(events.NewMessage(chats=pru))
response = await response
themssg = response.message.message
if themssg == "/cancel":
return await conv.send_message(
"Cancelled!!",
buttons=get_back_button("apiset"),
)
await setit(event, var, themssg)
await conv.send_message(
f"{name} changed to {themssg}",
buttons=get_back_button("apiset"),
)