added mute
This commit is contained in:
parent
5125e34077
commit
501870ca93
1 changed files with 33 additions and 1 deletions
34
main.py
34
main.py
|
@ -1,3 +1,4 @@
|
||||||
|
import asyncio
|
||||||
import time
|
import time
|
||||||
import pyrogram
|
import pyrogram
|
||||||
from pyrogram import Client, filters, enums, types
|
from pyrogram import Client, filters, enums, types
|
||||||
|
@ -97,7 +98,34 @@ async def source(client, message: Message):
|
||||||
await message.reply("I am free software! You can look at my code on https://git.nin0.dev/nin0/venbot-tg", disable_web_page_preview=True)
|
await message.reply("I am free software! You can look at my code on https://git.nin0.dev/nin0/venbot-tg", disable_web_page_preview=True)
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Moderation
|
||||||
|
@app.on_message(filters.command(["mute", "shutup", "restrict"], prefixes=P))
|
||||||
|
async def mute(client, message: Message):
|
||||||
|
moderator = await message.chat.get_member(message.from_user.id)
|
||||||
|
if not moderator.permissions.can_change_info:
|
||||||
|
await message.reply("You can't do this!")
|
||||||
|
return
|
||||||
|
args = message.text.split(" ")
|
||||||
|
if message.reply_to_message:
|
||||||
|
reason = message.text.replace("vmute ", "").replace("vrestrict ", "").replace("vshutup ", "")
|
||||||
|
await message.chat.restrict_member(message.reply_to_message.from_user.id, pyrogram.types.ChatPermissions(can_send_messages=False, can_send_media_messages=False, can_send_other_messages=False, can_send_polls=False, can_add_web_page_previews=False, can_change_info=False, can_invite_users=False, can_pin_messages=False))
|
||||||
|
|
||||||
|
await message.reply(f"Done!\n\n Muted user {message.reply_to_message.from_user.mention} with the reason of `{reason}`")
|
||||||
|
return
|
||||||
|
|
||||||
|
supposed_username = args[1]
|
||||||
|
if not supposed_username.startswith("@"):
|
||||||
|
await message.reply("Either mention the user, or if they don't have a public username, reply to their message.")
|
||||||
|
return
|
||||||
|
|
||||||
|
user = await app.get_users([supposed_username.replace("@", "")])
|
||||||
|
await message.chat.restrict_member(user.id, pyrogram.types.ChatPermissions(can_send_messages=False, can_send_media_messages=False, can_send_other_messages=False, can_send_polls=False, can_add_web_page_previews=False, can_change_info=False, can_invite_users=False, can_pin_messages=False))
|
||||||
|
|
||||||
|
await message.reply(f"Done!\n\n Muted user {user.mention} with the reason of `{reason}`")
|
||||||
|
#endregion
|
||||||
|
|
||||||
cur.execute("CREATE TABLE IF NOT EXISTS gambles(id, state, emoji)")
|
cur.execute("CREATE TABLE IF NOT EXISTS gambles(id, state, emoji)")
|
||||||
|
cur.execute("CREATE TABLE IF NOT EXISTS cases(id, target_user, responsible_user, type, reason)")
|
||||||
db.commit()
|
db.commit()
|
||||||
@app.on_message()
|
@app.on_message()
|
||||||
async def message_handler(client, message: Message):
|
async def message_handler(client, message: Message):
|
||||||
|
@ -123,4 +151,8 @@ async def message_handler(client, message: Message):
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
print("EX;" + ex)
|
print("EX;" + ex)
|
||||||
|
|
||||||
app.run()
|
def main():
|
||||||
|
print("Starting venbot-tg")
|
||||||
|
app.run()
|
||||||
|
|
||||||
|
main()
|
Loading…
Reference in a new issue