mirror of
https://github.com/Nick80835/microbot
synced 2025-08-31 14:38:04 +00:00
add chance parameter
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
import asyncio
|
||||
from random import randint
|
||||
from re import escape, search
|
||||
|
||||
from telethon import events, functions, types
|
||||
@@ -68,19 +69,35 @@ class CommandHandler():
|
||||
await event.reply(f"That command is currently locked: {value['lockreason']}")
|
||||
continue
|
||||
else:
|
||||
value["lockreason"] = f"In use by **{event.from_id}** (`{event.raw_text}`)"
|
||||
await value["function"](event)
|
||||
value["lockreason"] = None
|
||||
if value["chance"]:
|
||||
if randint(0, 100) <= value["chance"]:
|
||||
value["lockreason"] = f"In use by **{event.from_id}** (`{event.raw_text}`)"
|
||||
await value["function"](event)
|
||||
value["lockreason"] = None
|
||||
else:
|
||||
value["lockreason"] = f"In use by **{event.from_id}** (`{event.raw_text}`)"
|
||||
await value["function"](event)
|
||||
value["lockreason"] = None
|
||||
elif value["userlocking"]:
|
||||
if event.from_id in value["lockedusers"]:
|
||||
await event.reply(f"Please don't spam that command.")
|
||||
continue
|
||||
else:
|
||||
value["lockedusers"].append(event.from_id)
|
||||
await value["function"](event)
|
||||
value["lockedusers"].remove(event.from_id)
|
||||
if value["chance"]:
|
||||
if randint(0, 100) <= value["chance"]:
|
||||
value["lockedusers"].append(event.from_id)
|
||||
await value["function"](event)
|
||||
value["lockedusers"].remove(event.from_id)
|
||||
else:
|
||||
value["lockedusers"].append(event.from_id)
|
||||
await value["function"](event)
|
||||
value["lockedusers"].remove(event.from_id)
|
||||
else:
|
||||
await value["function"](event)
|
||||
if value["chance"]:
|
||||
if randint(0, 100) <= value["chance"]:
|
||||
await value["function"](event)
|
||||
else:
|
||||
await value["function"](event)
|
||||
except Exception as exception:
|
||||
value["lockreason"] = None
|
||||
|
||||
|
@@ -83,7 +83,8 @@ class Loader():
|
||||
"locking": args.get('locking', False),
|
||||
"lockreason": None,
|
||||
"userlocking": args.get('userlocking', False),
|
||||
"lockedusers": []
|
||||
"lockedusers": [],
|
||||
"chance": args.get('chance', None)
|
||||
})
|
||||
|
||||
return func
|
||||
|
@@ -65,12 +65,12 @@ async def floor(event):
|
||||
await event.reply("FLOOOOOOOOOOOOOOOOOOR")
|
||||
|
||||
|
||||
@ldr.add(f"bruh", simple_pattern=True, hide_help=True)
|
||||
@ldr.add(f"bruh", simple_pattern=True, hide_help=True, chance=50)
|
||||
async def bruh_moment(event):
|
||||
if not event.args:
|
||||
await event.reply("moment")
|
||||
|
||||
|
||||
@ldr.add(f"(^| )moo( |$)", raw_pattern=True, hide_help=True)
|
||||
@ldr.add(f"(^| )moo( |$)", raw_pattern=True, hide_help=True, chance=50)
|
||||
async def moo(event):
|
||||
await event.reply(choice(moo_answers))
|
||||
|
Reference in New Issue
Block a user