Skip to content

Commit

Permalink
Remove chat mode
Browse files Browse the repository at this point in the history
  • Loading branch information
MycroftKang committed Nov 30, 2023
1 parent afd35c6 commit 5d1469e
Show file tree
Hide file tree
Showing 13 changed files with 179 additions and 2,667 deletions.
4 changes: 4 additions & 0 deletions changelogs/unreleased/remove-chat-mode.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Remove chat mode
pull_request:
type: changes
14 changes: 0 additions & 14 deletions locales/mkbot.pot
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,6 @@ msgstr ""
msgid "Challenge declined :("
msgstr ""

msgid "Chat mode is not activated."
msgstr ""

msgid "Chat mode is only available when you have access to the **MK Bot Support Server**."
msgstr ""

msgid "Chose %s"
msgstr ""

Expand Down Expand Up @@ -229,11 +223,6 @@ msgstr ""
msgid "Help"
msgstr ""

msgid ""
"I think you told me about the `{command}` command, but I am not confident that I have understood you correctly.\n"
"Please try rephrasing your instruction to me."
msgstr ""

msgid "Installing... `%s`"
msgstr ""

Expand Down Expand Up @@ -317,9 +306,6 @@ msgstr ""
msgid "Leaves voice channel where the user who typed the command is in."
msgstr ""

msgid "Loading chat mode... Please try again later."
msgstr ""

msgid "Loading... `%s`"
msgstr ""

Expand Down
2,484 changes: 29 additions & 2,455 deletions poetry.lock

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ simpleaudio = "1.0.4"
sqlalchemy = "1.4.46"
yt-dlp = "2023.09.24"
mulgyeol-telemetry = {git = "https://github.com/MycroftKang/application-insights-python.git", rev = "c123c9b165faa8afe1fe3bf9a6b76a7b9afae0ce", optional = true}
mkbot-nlu = [
{git = "https://github.com/mgylabs/mkbot-nlu.git", rev = "7bbb76125a827581020fc1618192382ecaff9d62"},
{git = "https://github.com/mgylabs/mkbot-nlu.git", rev = "7bbb76125a827581020fc1618192382ecaff9d62", extras = ["full"], optional = true},
]

[tool.poetry.group.dev.dependencies]
black = "22.3.0"
Expand All @@ -54,4 +50,3 @@ pytest-mock = "3.10.0"

[tool.poetry.extras]
release = ["mulgyeol-telemetry"]
full = ["mkbot-nlu"]
13 changes: 8 additions & 5 deletions src/bot/core/controllers/discord/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import asyncio
# import asyncio

import discord
from discord.ext import commands
Expand All @@ -7,10 +7,12 @@
from mgylabs.i18n import _
from mgylabs.utils import logger
from mgylabs.utils.config import CONFIG
from mgylabs.utils.nlu import NluModel

from .utils.MGCert import Level, MGCertificate

# from mgylabs.utils.nlu import NluModel


log = logger.get_logger(__name__)


Expand All @@ -22,8 +24,9 @@ def __init__(self, bot):
self.unload_working = set()

async def load_nlu_model(self):
loop = asyncio.get_event_loop()
await loop.run_in_executor(None, NluModel.load, True)
pass
# loop = asyncio.get_event_loop()
# await loop.run_in_executor(None, NluModel.load, True)

@commands.command(hidden=True)
@MGCertificate.verify(level=Level.ADMIN_USERS)
Expand Down Expand Up @@ -106,7 +109,7 @@ async def unload(self, ctx: commands.Context, *, query):
msg = await ctx.send(f"{Emoji.typing} " + _("Unloading... `%s`") % query)

log.info(f"Unloading {query}...")
NluModel.unload()
# NluModel.unload()
log.info(f"Successfully unloaded {query}...")

await msg.edit(content=_("🟢 Successfully unloaded `%s`") % query)
Expand Down
13 changes: 6 additions & 7 deletions src/bot/core/controllers/discord/delete.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from discord.ext import commands
from mkbot_nlu.utils import Intent, register_intent

from mgylabs.i18n import _
from mgylabs.utils.LogEntry import DiscordEventLogEntry
Expand Down Expand Up @@ -40,12 +39,12 @@ async def delete(ctx: commands.Context, amount):
DiscordEventLogEntry.Add(ctx, "MessageDeleted", {"count": int(amount)})


@register_intent("command::delete", "delete")
def cmd_delete(intent: Intent):
if amount := intent.get_an_entity("amount"):
return f"delete {amount}"
else:
return "delete 2"
# @register_intent("command::delete", "delete")
# def cmd_delete(intent: Intent):
# if amount := intent.get_an_entity("amount"):
# return f"delete {amount}"
# else:
# return "delete 2"


async def setup(bot: commands.Bot):
Expand Down
7 changes: 3 additions & 4 deletions src/bot/core/controllers/discord/lotto.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import random

from discord.ext import commands
from mkbot_nlu.utils import Intent, register_intent

from mgylabs.i18n import _

Expand Down Expand Up @@ -44,9 +43,9 @@ async def lotto(ctx: commands.Context):
)


@register_intent("command::lotto", "lotto")
def cmd_lotto(intent: Intent):
return "lotto"
# @register_intent("command::lotto", "lotto")
# def cmd_lotto(intent: Intent):
# return "lotto"


async def setup(bot: commands.Bot):
Expand Down
25 changes: 12 additions & 13 deletions src/bot/core/controllers/discord/music.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import discord
from bs4 import BeautifulSoup
from discord.ext import commands
from mkbot_nlu.utils import Intent, register_intent
from yt_dlp import YoutubeDL

from core.controllers.discord.utils import Emoji
Expand Down Expand Up @@ -602,22 +601,22 @@ async def on_voice_state_update(self, member, before, after):
)


@register_intent("command::music::play", "play")
def cmd_play(intent: Intent):
if query := intent.get_an_entity("music_query"):
return f"play {query}"
else:
return "play"
# @register_intent("command::music::play", "play")
# def cmd_play(intent: Intent):
# if query := intent.get_an_entity("music_query"):
# return f"play {query}"
# else:
# return "play"


@register_intent("command::music::skip", "skip")
def cmd_skip(intent: Intent):
return "skip"
# @register_intent("command::music::skip", "skip")
# def cmd_skip(intent: Intent):
# return "skip"


@register_intent("command::music::stop", "stop")
def cmd_stop(intent: Intent):
return "stop"
# @register_intent("command::music::stop", "stop")
# def cmd_stop(intent: Intent):
# return "stop"


async def setup(bot: commands.Bot):
Expand Down
17 changes: 8 additions & 9 deletions src/bot/core/controllers/discord/roulette.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import discord
from discord.ext import commands
from mkbot_nlu.utils import Intent, register_intent

from mgylabs.i18n import _
from mgylabs.utils.LogEntry import DiscordEventLogEntry
Expand Down Expand Up @@ -46,14 +45,14 @@ async def roulette(ctx: commands.Context, *items):
)


@register_intent("command::roulette", "roulette")
def cmd_roulette(intent: Intent):
if items := intent.get_an_entity("items"):
items: str
items = [i.strip() for i in items.split(",")]
return "roulette " + " ".join(f'"{i}"' for i in items)
else:
return None
# @register_intent("command::roulette", "roulette")
# def cmd_roulette(intent: Intent):
# if items := intent.get_an_entity("items"):
# items: str
# items = [i.strip() for i in items.split(",")]
# return "roulette " + " ".join(f'"{i}"' for i in items)
# else:
# return None


async def setup(bot: commands.Bot):
Expand Down
17 changes: 8 additions & 9 deletions src/bot/core/controllers/discord/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from discord import app_commands
from discord.ext import commands
from langdetect import detect
from mkbot_nlu.utils import Intent, register_intent

from core.controllers.discord.utils.command_helper import send
from mgylabs.i18n import L_, _
Expand Down Expand Up @@ -295,15 +294,15 @@ async def _request_api(self, headers, params):
}


@register_intent("command::translate::translate", "translate")
def cmd_translate(intent: Intent):
query = intent.get_an_entity("trans_query")
lang = intent.get_an_entity("language")
# @register_intent("command::translate::translate", "translate")
# def cmd_translate(intent: Intent):
# query = intent.get_an_entity("trans_query")
# lang = intent.get_an_entity("language")

if query:
return f'translate "{intent.get_an_entity("trans_query")}" {ko2langcode.get(lang, "en")}'
else:
return None
# if query:
# return f'translate "{intent.get_an_entity("trans_query")}" {ko2langcode.get(lang, "en")}'
# else:
# return None


async def setup(bot: commands.Bot):
Expand Down
2 changes: 1 addition & 1 deletion src/bot/discord_ext.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
discord_extensions = (
"core.controllers.discord.dev",
"core.controllers.discord.admin",
# "core.controllers.discord.admin",
"core.controllers.discord.delete",
"core.controllers.discord.join",
"core.controllers.discord.leave",
Expand Down
Loading

0 comments on commit 5d1469e

Please sign in to comment.