-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7ed45e6
commit 52577e9
Showing
7 changed files
with
65 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,13 @@ | ||
import _pickle as pickle | ||
from kreacher import client | ||
from pytgcalls import GroupCallFactory | ||
VOICE_CHATS = {} | ||
|
||
VOICE_CHATS_FILE = "voice_chats.pkl" | ||
|
||
try: | ||
with open(VOICE_CHATS_FILE, "rb") as file: | ||
VOICE_CHATS = pickle.load(file) | ||
except (FileNotFoundError, EOFError): | ||
VOICE_CHATS = {} | ||
def get_voice_chat(chat): | ||
return VOICE_CHATS.get(chat.id) | ||
|
||
|
||
async def create_voice_chat(chat_id): | ||
factory = GroupCallFactory(client, GroupCallFactory.MTPROTO_CLIENT_TYPE.TELETHON) | ||
voice_chat = factory.get_group_call() | ||
print(dir(voice_chat)) | ||
get = VOICE_CHATS.get(chat_id) | ||
if get is not None: | ||
raise Exception("I'm joined in the Voice Chat") | ||
def start_voice_chat(chat, instance): | ||
VOICE_CHATS[chat.id] = instance | ||
|
||
VOICE_CHATS[chat_id] = voice_chat | ||
|
||
with open(VOICE_CHATS_FILE, "wb") as file: | ||
pickle.dump(VOICE_CHATS, file) | ||
|
||
|
||
async def get_voice_chat(chat_id): | ||
voice_chat = VOICE_CHATS.get(chat_id) | ||
return voice_chat | ||
|
||
|
||
async def stop_voice_chat(chat_id): | ||
voice_chat = VOICE_CHATS.get(chat_id) | ||
|
||
if voice_chat is None: | ||
raise Exception("Streaming is not started") | ||
|
||
del VOICE_CHATS[chat_id] | ||
|
||
with open(VOICE_CHATS_FILE, "wb") as file: | ||
pickle.dump(VOICE_CHATS, file) | ||
async def stop_voice_chat(chat): | ||
VOICE_CHATS.pop(chat.id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
from kreacher import kreacher | ||
from kreacher.helpers.voice_chats import get_voice_chat, create_voice_chat | ||
from kreacher import ins, kreacher | ||
from kreacher.helpers.voice_chats import get_voice_chat, start_voice_chat | ||
from telethon import events | ||
|
||
|
||
@kreacher.on(events.NewMessage(pattern="[!?/]join")) | ||
async def join_handler(event): | ||
try: | ||
chat = await event.get_chat() | ||
call_py = await get_voice_chat(chat.id) | ||
if call_py is not None: | ||
proto = get_voice_chat(chat) | ||
if proto is not None: | ||
raise Exception("Streaming is active") | ||
await create_voice_chat(chat.id) | ||
await call_py.start(chat.id) | ||
start_voice_chat(chat, ins) | ||
await proto.join(chat) | ||
await event.reply("<i>Master, what do you need? \n\nVoice Chat joined successfully.</i>", parse_mode="HTML") | ||
except Exception as e: | ||
return await event.reply(f"<i>Oops master, something wrong has happened. \n\nError:</i> <code>{e}</code>", parse_mode="HTML") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters