-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcoin-flipper.py
53 lines (44 loc) · 1.93 KB
/
coin-flipper.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
# Friendly Telegram (telegram userbot)
# Copyright (C) 2018-2020 The Authors
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import random
import logging
from asyncio import sleep
from .. import loader, utils
logger = logging.getLogger(__name__)
def register(cb):
cb(CoinFlipperMod())
OPTIONS = ["❌", "🟤"]
class CoinFlipperMod(loader.Module):
"""Coin flipper mod"""
strings = {"name": "CoinFlipper"}
def __init__(self):
self.config = loader.ModuleConfig("OPTIONS", OPTIONS, "options")
async def coincmd(self, message):
""".coin Flips a coin"""
args = utils.get_args_raw(message)
tries = int(3)
if args:
try:
tries = int(args)
except ValueError:
await utils.answer(message,"<code>Error</code>")
await utils.answer(message,"<code>Lanzando una moneda " + str(tries) + " veces...</code>")
await sleep(1)
for i in range(tries):
i += 1
msg = random.choice(OPTIONS)
await sleep(1)
await utils.answer(message,"<code>" + msg + " (#" + str(i) + ")</code>")
if i == tries:
await sleep(1)
await utils.answer(message,"<code> Ha salido " + msg + " en " + str(i) + " tiradas.</code>")