Ejemplo n.º 1
0
from hata import Client

# Replace this with your bot token, see topics/getting_started.md to see how you can get one
TOKEN = ''

# Create your client instance by using your bot token
Sakuya = Client(TOKEN)


# Register event handler for message create event. When a message is received the decorated function will be called.
#
# Events are dispatched asynchronously so multiple events can be handled in parallel.
@Sakuya.events
async def message_create(client, message):
    if message.content == '!ping':
        # Sending message can fail due to network error or by lack of permissions.
        #
        # If exception is not explicitly caught it will be logged to stderr and ignored.
        await client.message_create(message.channel, 'pong')


# Register handler for the `ready` event. Ready is called when the client shards are all booted up.
@Sakuya.events
async def ready(client):
    # Hata has various format codes for Discord entities
    #
    # In this case `f` stands for `.full_name` property.
    print(f'{client:f} is connected!')


Sakuya.start()
Ejemplo n.º 2
0
from dotenv import dotenv_values
from hata import Client, wait_for_interruption
from hata.ext.extension_loader import EXTENSION_LOADER

config = dotenv_values('.env')

Sakuya = Client(
    config['TOKEN'],
    extensions='commands_v2',
    prefix='!',
)


@Sakuya.events
async def ready(client):
    print(f'{client:f} is connected!')


# Registered variables to extension loader, show up in each loaded extension file.
EXTENSION_LOADER.add_default_variables(Sakuya=Sakuya)
# Adds the extensions file or the extensions files recursive in the folder
EXTENSION_LOADER.add('modules')
# Loads all the added extension files.
EXTENSION_LOADER.load_all()

Sakuya.start()

wait_for_interruption()
Ejemplo n.º 3
0
from hata import Client, start_clients, User, Embed, UserBase, ChannelBase
from hata.ext.commands import (
    setup_extension,
    Converter,
    ConverterFlag,
    checks,
    FlaggedAnnotation,
)

from cute_commands import cute_commands

OWO_RP = re.compile('owo|uwu|0w0', re.I)
AYY_RP = re.compile('ay+', re.I)

TOKEN = ''
NekoBot = Client(TOKEN)

setup_extension(NekoBot, 'n!')

NekoBot.commands.extend(cute_commands)


@NekoBot.commands
async def pat(client, message):
    await client.message_create(message.channel, 'Puurs !')


@NekoBot.commands(name='print', alises=['say'])
async def print_(client, message, content):
    if content:
        await client.message_create(message.channel, content)
Ejemplo n.º 4
0
from hata import Client, Message, Embed
import json
from hata.ext.commands import setup_ext_commands
from character import *
from hata import KOKORO, Lock, enter_executor

import cattr

FILE_LOCK = Lock(KOKORO)

secrets = json.load(open('secrets.json'))
Faito = Client(secrets['token'])
setup_ext_commands(Faito, '!')
# dictionary pointing user.id -> character
characters = {}
# list of battles
battles = []
battle_locks = []
characters_lock = Lock(KOKORO)


@Faito.events
async def ready(client):
    print(f'{client:f} logged in.')


@Faito.commands
async def ping(client, message):
    await client.message_create(message.channel, 'pong')

Ejemplo n.º 5
0
from hata import Client, start_clients, ClientWrapper

TOKEN_1 = ''
TOKEN_2 = ''
TOKEN_3 = ''

Sakuya = Client(TOKEN_1)
Remilia = Client(TOKEN_2)
Flandre = Client(TOKEN_3)

# With `ClientWrapper` you can add event handler to all clients...
ALL = ClientWrapper()

# ...or just for specific clients.
ONLY_SAKUYA_AND_REMILIA = ClientWrapper(Sakuya, Remilia)


@ALL.events
async def ready(client):
    # This event is registered for all (currently 3) clients
    print(f'{client:f} is connected!')


@ONLY_SAKUYA_AND_REMILIA.events
async def message_create(client, message):
    # This event is registered only to Sakuya and Remilia
    # When either of them see message that is '!basement' they will reply with 'nope'
    if message.content == '!basement':
        await client.message_create(message.channel, 'nope')

Ejemplo n.º 6
0
from hata import Client, Guild

TOKEN = ''

# The `slash` framework
#
# Your bot needs to have `applications.commands` scope in the guilds, or it's slash commands wont show up. Note, that
# if you have 50 or more bots in the guild, it still wont work.
Sakuya = Client(TOKEN,
    extensions = 'slash',
)

# Using `Guild.precreate(guild_id, ...)` is a great way to get a reference to a not yet loaded entity.
MY_GUILD = Guild.precreate(123456)

@Sakuya.events
async def ready(client):
    print(f'{client:f} is connected!')


# Slash commands can be registered with the `.interactions` decorator if the client has slash extension setuped.
#
# Passing `is_global=True` will make the command global. These commands are available in each guild and in dm as well.
# Global command updates are distributed after 1 hour.
@Sakuya.interactions(is_global=True)
async def ping():
    """A ping command"""
    return 'pong'


# `guild=...` parameter will make the command guild bound.
Ejemplo n.º 7
0
#
# We're using `commands_v2` extension since it provides an easy API to access user voice state or the local voice client
#
# The example will showcase the following actions:
# => Connecting to voice channel.
# => Changing volume.
# => Playing audio from youtube.
# => Disconnecting.

from hata import Client, YTAudio, DownloadError
from hata.ext.commands_v2 import checks

TOKEN = ''

Sakuya = Client(TOKEN,
    extensions = 'commands_v2',
    prefix = '!',
)


@Sakuya.events
async def ready(client):
    print(f'{client:f} is connected!')


@Sakuya.commands
@checks.guild_only()
async def join(ctx):
    """Joins to voice channel."""
    # Getting the author voice state
    voice_state = ctx.voice_state
    if voice_state is None:
Ejemplo n.º 8
0
from hata import Client, ActivityRich, ACTIVITY_TYPES
from hata.ext.extension_loader import EXTENSION_LOADER
from bot_utils.shared import PATH__KOISHI

from bot_utils.shared import category_name_rule, DEFAULT_CATEGORY_NAME, PREFIX__MARISA, PREFIX__FLAN, PREFIX__SATORI

MARISA_MODE = config.MARISA_MODE
EXTENSION_LOADER.add_default_variables(MARISA_MODE=MARISA_MODE)

if MARISA_MODE:
    Marisa = Client(
        config.MARISA_TOKEN,
        client_id=config.MARISA_ID,
        http_debug_options='canary',
        extensions=('command_utils', 'slash', 'commands_v2'),
        prefix=PREFIX__MARISA,
        default_category_name=DEFAULT_CATEGORY_NAME,
        category_name_rule=category_name_rule,
    )

    EXTENSION_LOADER.add_default_variables(Marisa=Marisa,
                                           COMMAND_CLIENT=Marisa,
                                           SLASH_CLIENT=Marisa)

    EXTENSION_LOADER.load_extension('bots.marisa', locked=True)

    EXTENSION_LOADER.add('bots.testers', MAIN_CLIENT=Marisa)

else:
    Koishi = Client(
Ejemplo n.º 9
0
from hata import Client, IntentFlag

TOKEN = ''

# Intents are bit flags thus bitwise operations can be used to dictate which intents are used.
# By default all gateway intents are used.
Sakuya = Client(TOKEN,
                intents=IntentFlag(0).update_by_keys(guilds=True,
                                                     guild_messages=True))


@Sakuya.events
async def ready(client):
    print(f'{client:f} is connected!')


# This event will be dispatched only for guilds but not for private channels.
@Sakuya.events
async def message_create(client, message):
    print(f'Received message: {message.content!r}')


# This event will never be dispatched.
@Sakuya.events
async def user_presence_update(client, user, old_attributes):
    print('Presence Update')


Sakuya.start()
Ejemplo n.º 10
0
import os

from hata import Client, start_clients
from hata.ext.slash import setup_ext_slash
from hata.ext import asyncio as hata_asyncio  # noqa
from hata.ext.commands import setup_ext_commands
from hata.ext.extension_loader import EXTENSION_LOADER

from database_handler import DatabaseHandler

braindead = Client("YOUR_TOKEN_HERE")
setup_ext_commands(braindead, "!")
setup_ext_slash(braindead)


@braindead.events
async def ready(client):
    print(f"{client:f} logged in.")


EXTENSION_LOADER.add_default_variables(braindead=braindead)

for name in os.listdir("modules"):
    if name.endswith(".py"):
        EXTENSION_LOADER.add(f"modules.{name[:-3]}")

braindead.loop.run(DatabaseHandler.create_connection())
EXTENSION_LOADER.load_all()
start_clients()
Ejemplo n.º 11
0
from hata import Client, Guild, sleep, Embed, Color, Emoji
from hata.ext.slash import setup_ext_slash
from dotenv import load_dotenv
from random import random, choice
import os, re

# loading the .env file
load_dotenv()

Token = os.environ.get('Token')
APPLICATION_ID = os.environ.get('APPLICATION_ID')
GUILD = Guild.precreate(os.environ.get('GUILD_ID'))

Pichu = Client(Token, application_id=APPLICATION_ID)
setup_ext_slash(Pichu)

# emotes
CAT_FISH = Emoji.precreate(os.environ.get('CAT_FISH'))
CAT_SAD = Emoji.precreate(os.environ.get('CAT_SAD'))
CAT_WAY = Emoji.precreate(os.environ.get('CAT_WAY'))
NEKOGIRL_KISS = Emoji.precreate(os.environ.get("NEKOGIRL_KISS"))
NEKOGIRL_PEEK = Emoji.precreate(os.environ.get('NEKOGIRL_PEEK'))

# colors
CAT_FACT_COLOR = Color.from_html('#F6D33C')
OwO_COLOR = Color.from_html('#FF69B4')
NEKOGIRL_COLOR = Color.from_html('#FFB6C1')
CAT_COLOR = Color.from_html('#000000')

# data
CAT_FACTS = [
Ejemplo n.º 12
0
from hata import Client, start_clients, sleep

from hata.events import CommandProcesser, ContentParser

from HaxLib import client, embeds

import json

with open('token.txt') as f:

    HaxBotToken = f.read().strip('\n')

    f.close()

Gateway = Client(HaxBotToken)

HaxBot = client(HaxBotToken)

embeds = embeds.embeds

on_command = Gateway.events(CommandProcesser('hl:')).shortcut

from string import ascii_lowercase, ascii_uppercase

emojis = [
    '🇦', '🇧', '🇨', '🇩', '🇪', '🇫', '🇬', '🇭', '🇮',
    '🇯', '🇰', '🇱', '🇲', '🇳', '🇴', '🇵', '🇶', '🇷',
    '🇸', '🇹', '🇺', '🇻', '🇼', '🇽', '🇾', '🇿'
]
Ejemplo n.º 13
0
    del (hata, flask)
except:
    os.system(
        'pip3 install https://github.com/HuyaneMatsu/hata/archive/master.zip flask'
    )

from flask import Flask, request
import json
from hata import Client, start_clients, events, Embed, enter_executor
from hata.events import Pagination, ReactionAddWaitfor, ReactionDeleteWaitfor
from hata.extension_loader import ExtensionLoader, ExtensionError

from pdaddons.python.hata.interpreter import Interpreter

token = os.environ.get('TOKEN')
pdbot = Client(token)

on_command = pdbot.events(events.CommandProcesser(
    os.environ.get('PREFIX'))).shortcut

pdbot.events(ReactionAddWaitfor)
pdbot.events(ReactionDeleteWaitfor)

EXTENSION_LOADER = ExtensionLoader(pdbot)


def add_extensions():
    async def entry(client, lib):
        commands = getattr(lib, 'commands', None)
        if commands is not None:
            pdbot.events.message_create.shortcut.extend(commands)
Ejemplo n.º 14
0
import os
import importlib
from dotenv import load_dotenv
from hata import Client, start_clients, events, Embed

extensions = ("mew", "fun")

load_dotenv()
hata_client = Client(os.getenv("BOT_TOKEN"))
on_command = hata_client.events(events.CommandProcesser("!")).shortcut

for extension in extensions:
    module = importlib.import_module(f"extensions.{extension}")
    on_command.extend(module.extension)


@hata_client.events
class Ready:
    def __init__(self):
        self.called = False

    async def __call__(self, client):
        login_message = f" --> {client:f} ({client.id}) logged in UwU"

        if self.called:
            print(f"Reconnected {login_message}")
            return
        self.called = True

        await client.update_application_info()
        print(f"Hello {client.owner:f} {login_message}")
Ejemplo n.º 15
0
# -*- coding: utf-8 -*-
import os

import config

from hata import Client, start_clients, ActivityRich, ActivityTypes
from hata.ext.extension_loader import EXTENSION_LOADER
from bot_utils.shared import KOISHI_PATH

MARISA_MODE = config.MARISA_MODE

EXTENSION_LOADER.add_default_variables(MARISA_MODE=MARISA_MODE)

if MARISA_MODE:
    Marisa = Client(
        config.MARISA_TOKEN,
        client_id=config.MARISA_ID,
    )

    EXTENSION_LOADER.add_default_variables(Marisa=Marisa, main_client=Marisa)

    EXTENSION_LOADER.load_extension('bots.marisa', locked=True)

    EXTENSION_LOADER.add('bots.testers.test_commands')
    EXTENSION_LOADER.add('bots.testers.ratelimit')
    EXTENSION_LOADER.add('bots.testers.dispatch_tests')

else:
    Koishi = Client(
        config.KOISHI_TOKEN,
        secret=config.KOISHI_SECRET,
        client_id=config.KOISHI_ID,
Ejemplo n.º 16
0
import os

from hata import Client, start_clients, ActivityRich, ActivityTypes, Status
from hata.ext.extension_loader import EXTENSION_LOADER

from bot_utils.database import My_Database

import config

MINT = Client(token=config.MINT_TOKEN,
              client_id=config.MINT_ID,
              status=None,
              activity=ActivityRich("Nihongo Quest",
                                    type_=ActivityTypes.watching))

MELON = Client(token=config.MELON_TOKEN,
               client_id=config.MELON_ID,
               status="dnd",
               activity=ActivityRich("The Server",
                                     type_=ActivityTypes.watching))

MELON_MINT = Client(token=config.MELON_MINT_TOKEN,
                    client_id=config.MELON_MINT_ID,
                    status='idle',
                    activity=ActivityRich("My Creator",
                                          type_=ActivityTypes.watching))

#Connecting to database
MELON_MINT.loop.run(My_Database.setup_firebase(config.FIREBASE_CONFIG))

EXTENSION_LOADER.add_default_variables(