1
0
Fork 0
mirror of https://github.com/inexcode/ixizi synced 2024-11-27 08:51:27 +00:00
This commit is contained in:
Inex Code 2019-01-24 20:39:28 +03:00
commit 6e131e9999
5 changed files with 169 additions and 0 deletions

10
config.json Normal file
View file

@ -0,0 +1,10 @@
{
"token": "<Your Discord token>",
"bot": {
"plugins": [
"plugins.dicer",
"plugins.references",
"plugins.coffee"
]
}
}

0
plugins/__init__.py Normal file
View file

102
plugins/coffee.py Normal file
View file

@ -0,0 +1,102 @@
from disco.bot import Bot, Plugin
import rolldice
from enum import Enum
class Drinks(Enum):
espresso = (1, "Эспрессо")
americano = (2, "Американо")
cappuccino = (3, "Капучино")
latte = (4, "Латте")
raf = (5, "Раф-кофе")
flat_white = (6, "Флэт Уайт")
mocachino = (7, "Мокаччино")
frappuchino = (8, "Фраппучино")
hot_chocolate = (9, "Горячий шоколад")
cacao = (10, "Какао")
milk_coctail = (11, "Молочный коктейль")
tea = (12, "Чай")
enjoy1 = (13, "Латте бельгийская вафля")
enjoy2 = (14, "Арахисовый капучино")
enjoy3 = (15, "Капучино кокосовый бисквит")
enjoy4 = (16, "Лавандовый раф")
enjoy5 = (17, "Грушевый раф с солёной карамелью")
enjoy6 = (18, "Чай с вишней и пряностями")
latte_tea = (19, "Латте чай")
feel_winter1 = (20, "Хвойный раф")
feel_winter2 = (21, "Раф грецкий орех в клиновом сиропе")
feel_winter3 = (22, "Чай шиповник-липа")
feel_winter4 = (23, "Чай японский лимон Юзу")
def __init__(self, id, title):
self.id = id
self.title = title
class Syrops(Enum):
syroup1 = (1, "Карамель")
syroup2 = (2, "Солёная карамель")
syroup3 = (3, "Банан")
syroup4 = (4, "Ваниль")
syroup5 = (5, "Миндаль")
syroup6 = (6, "Кокос")
syroup7 = (7, "Кленовый")
syroup8 = (8, "Клубника")
syroup9 = (9, "Чёрная смородина")
syroup10 = (10, "Имбирный пряник")
syroup11 = (11, "Личи")
syroup12 = (12, "Шоколад")
syroup13 = (13, "Амаретто")
syroup14 = (14, "Ирландский крем")
sugar = (15, "Ванильный сахар")
combo1 = (16, "Солёная карамель и имбирный пряник")
def __init__(self, id, title):
self.id = id
self.title = title
class Teas(Enum):
green = (1, "Зелёный")
black = (2, "Чёрный")
fruit = (3, "Фруктовый")
def __init__(self, id, title):
self.id = id
self.title = title
class CoffeePlugin(Plugin):
@Plugin.command('coffee', '[param:str]')
def on_coffee(self, event, param=''):
try:
result = ""
if param.lower() == 'classic':
result1, expl1 = rolldice.roll_dice('1d12')
elif param.lower() == 'raf':
result1, expl1 = (5, 'User')
else:
result1, expl1 = rolldice.roll_dice('1d23')
result += list(Drinks)[result1-1].title
if result1 == 5:
result2, expl2 = rolldice.roll_dice('1d18')
if result2 > 16:
result2, expl2 = rolldice.roll_dice('1d15')
result21, expl21 = rolldice.roll_dice('1d15')
result += "\n**Сиропы**: {} и {}".format(list(Syrops)[result2 - 1].title, list(Syrops)[result21 - 1].title)
else:
result += "\n**Сироп**: {}".format(list(Syrops)[result2 - 1].title)
elif result1 == 9:
result2, expl2 = rolldice.roll_dice('1d2')
if result2 == 1:
result += "\nТёмный"
else:
result += "\nМолочный"
elif result1 == 12 or result1 == 19:
result2, expl2 = rolldice.roll_dice('1d3')
result += " {}".format(list(Teas)[result2 - 1].title)
except Exception as e:
event.msg.reply(str(e))
else:
event.msg.reply(result)

22
plugins/dicer.py Normal file
View file

@ -0,0 +1,22 @@
from disco.bot import Bot, Plugin
import rolldice
class TestPlugin(Plugin):
@Plugin.command('roll', '<dice:str> [comment:str...]')
def on_roll(self, event, dice, comment=''):
try:
result, explanation = rolldice.roll_dice(dice)
except rolldice.DiceGroupException as e:
event.msg.reply(str(e))
except rolldice.DiceOperatorException as e:
event.msg.reply(str(e))
except Exception as e:
event.msg.reply(str(e))
else:
if comment:
event.msg.reply(
'{} rolled *{}* \n **{}** \t`{}`'.format(str(event.msg.author)[:-5], comment, result, explanation))
else:
event.msg.reply(
'{} rolled a dice! \n **{}** \t`{}`'.format(str(event.msg.author)[:-5], result, explanation))

35
plugins/references.py Normal file
View file

@ -0,0 +1,35 @@
from disco.bot import Bot, Plugin
from disco.types.message import MessageEmbed
import firebase_admin
from firebase_admin import credentials
from firebase_admin import db
# Auth
cred = credentials.Certificate('firebase-key.json')
firebase_admin.initialize_app(cred, {
'databaseURL': 'https://<your-project-id>.firebaseio.com'
})
class RefPlugin(Plugin):
@Plugin.command('ref', '<character:str>')
def on_red(self, event, character):
try:
dbref = db.reference('references/{}'.format(character.lower()))
data = dbref.get()
if data:
embed = MessageEmbed()
embed.set_author(name=data.get('owner', 'Unknown owner'), url=data.get('ownerURL'), icon_url=data.get('ownerAvatar'))
embed.title = data.get('name', 'Unnamed')
if data.get('description'):
embed.description = data['description']
embed.color = data['color']
if data.get('image'):
embed.set_image(url=data['image'])
if data.get('thumbnail'):
embed.set_thumbnail(url=data['thumbnail'])
event.msg.reply(embed=embed)
else:
event.msg.reply("Not found")
except Exception as e:
event.msg.reply(str(e))