-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathcallcontrol.py
50 lines (41 loc) · 1.68 KB
/
callcontrol.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
# -*- coding: utf-8 -*-
# Module author: @dekftgmodules
from asyncio import sleep
from telethon import functions
from .. import loader, utils
@loader.tds
class VGCallControllerMod(loader.Module):
"""Control group voice calls"""
strings = {"name": "VGCallController"}
@loader.owner
async def callstartcmd(self, m):
"""Start call in chat"""
if not m.chat:
return await utils.answer(m, "<b>[VGCallController]</b> It is not a chat!")
call = (
await m.client(functions.channels.GetFullChannelRequest(m.chat.id))
).full_chat.call
if not call:
try:
await m.client(functions.phone.CreateGroupCallRequest(peer=m.chat))
await utils.answer(m, "<b>[VGCallController]</b> Call started!")
except:
await utils.answer(m, "<b>[VGCallController]</b> Err...")
else:
await utils.answer(m, "<b>[VGCallController]</b> There is call now!")
async def callstopcmd(self, m):
"""Stop call in chat"""
if not m.chat:
return await utils.answer(m, "<b>[VGCallController]</b> It is not a chat!")
call = (
await m.client(functions.channels.GetFullChannelRequest(m.chat.id))
).full_chat.call
if call:
try:
await m.client(functions.phone.DiscardGroupCallRequest(call))
await utils.answer(m, "<b>[VGCallController]</b> Call stopped!")
await sleep(5)
except:
await utils.answer(m, "<b>[VGCallController]</b> Err...")
else:
await utils.answer(m, "<b>[VGCallController]</b> There is no call now!")