Skip to content

Commit

Permalink
Merge pull request #147 from satisfactorymodding/no-dialogflow
Browse files Browse the repository at this point in the history
Remove DialogFlow entirely
  • Loading branch information
Borketh authored Oct 11, 2024
2 parents b58b0e4 + 2e765de commit 17cf3a6
Show file tree
Hide file tree
Showing 13 changed files with 9 additions and 705 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ Docker is for making containers. If you're not sure what that means, look it up
You can get docker [here](https://docs.docker.com/engine/install/). For Linux, make sure to **not** use Docker Desktop. For Windows, it is the easiest way.
If you don't want to install Docker (especially on Windows where Docker Desktop can take up resources and requires virtualisation to be enabled), you can also manually set up a PostgreSQL DB and configure Fred to point to it. More on that later.

#### (Optional) Dialogflow auth

This is optional because this feature is currently disabled in Fred.
You'll have get authentication information for dialogflow if you want to work on that.

### Setup

Two choices here: All through docker or hybrid local/docker.
Expand Down
118 changes: 0 additions & 118 deletions docker/exampledb.sql
Original file line number Diff line number Diff line change
Expand Up @@ -140,124 +140,6 @@ ALTER TABLE public.crashes_id_seq OWNER TO fred;

ALTER SEQUENCE public.crashes_id_seq OWNED BY public.crashes.id;


--
-- TOC entry 211 (class 1259 OID 16442)
-- Name: dialogflow; Type: TABLE; Schema: public; Owner: fred
--

CREATE TABLE public.dialogflow (
id integer NOT NULL,
intent_id text,
data text,
response text,
has_followup boolean
);


ALTER TABLE public.dialogflow OWNER TO fred;

--
-- TOC entry 207 (class 1259 OID 16426)
-- Name: dialogflow_channels; Type: TABLE; Schema: public; Owner: fred
--

CREATE TABLE public.dialogflow_channels (
id integer NOT NULL,
channel_id bigint
);


ALTER TABLE public.dialogflow_channels OWNER TO fred;

--
-- TOC entry 206 (class 1259 OID 16424)
-- Name: dialogflow_channels_id_seq; Type: SEQUENCE; Schema: public; Owner: fred
--

CREATE SEQUENCE public.dialogflow_channels_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;


ALTER TABLE public.dialogflow_channels_id_seq OWNER TO fred;

--
-- TOC entry 3077 (class 0 OID 0)
-- Dependencies: 206
-- Name: dialogflow_channels_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: fred
--

ALTER SEQUENCE public.dialogflow_channels_id_seq OWNED BY public.dialogflow_channels.id;


--
-- TOC entry 209 (class 1259 OID 16434)
-- Name: dialogflow_exception_roles; Type: TABLE; Schema: public; Owner: fred
--

CREATE TABLE public.dialogflow_exception_roles (
id integer NOT NULL,
role_id bigint
);


ALTER TABLE public.dialogflow_exception_roles OWNER TO fred;

--
-- TOC entry 208 (class 1259 OID 16432)
-- Name: dialogflow_exception_roles_id_seq; Type: SEQUENCE; Schema: public; Owner: fred
--

CREATE SEQUENCE public.dialogflow_exception_roles_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;


ALTER TABLE public.dialogflow_exception_roles_id_seq OWNER TO fred;

--
-- TOC entry 3078 (class 0 OID 0)
-- Dependencies: 208
-- Name: dialogflow_exception_roles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: fred
--

ALTER SEQUENCE public.dialogflow_exception_roles_id_seq OWNED BY public.dialogflow_exception_roles.id;


--
-- TOC entry 210 (class 1259 OID 16440)
-- Name: dialogflow_id_seq; Type: SEQUENCE; Schema: public; Owner: fred
--

CREATE SEQUENCE public.dialogflow_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;


ALTER TABLE public.dialogflow_id_seq OWNER TO fred;

--
-- TOC entry 3079 (class 0 OID 0)
-- Dependencies: 210
-- Name: dialogflow_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: fred
--

ALTER SEQUENCE public.dialogflow_id_seq OWNED BY public.dialogflow.id;


--
-- TOC entry 205 (class 1259 OID 16418)
-- Name: media_only_channels; Type: TABLE; Schema: public; Owner: fred
Expand Down
1 change: 0 additions & 1 deletion fred/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"FRED_SQL_PASSWORD",
"FRED_SQL_HOST",
"FRED_SQL_PORT",
# "DIALOGFLOW_AUTH",
)

for var in ENVVARS:
Expand Down
129 changes: 0 additions & 129 deletions fred/cogs/dialogflow.py

This file was deleted.

46 changes: 0 additions & 46 deletions fred/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,52 +113,6 @@ def check(channel_id: int) -> bool:
return bool(MediaOnlyChannels.selectBy(channel_id=channel_id).getOne(False))


class DialogflowChannels(SQLObject):
class sqlmeta:
table = "dialogflow_channels"

channel_id = BigIntCol()

@staticmethod
def check(channel_id: int) -> bool:
return bool(DialogflowChannels.selectBy(channel_id=channel_id).getOne(False))


class DialogflowExceptionRoles(SQLObject):
class sqlmeta:
table = "dialogflow_exception_roles"

role_id = BigIntCol()

@staticmethod
def check(role_id: int) -> bool:
return bool(DialogflowExceptionRoles.selectBy(role_id=role_id).getOne(False))

@staticmethod
def fetch_all() -> list[int]:
query = DialogflowExceptionRoles.select()
return [role.role_id for role in query.lazyIter()]


class Dialogflow(SQLObject):
intent_id = StringCol()
data = StringCol()
response = StringCol()
has_followup = BoolCol()

def as_dict(self) -> dict[str, Any]:
return dict(
intent_id=self.intent_id,
data=json.loads(str(self.data)) if self.data else None,
response=self.response,
has_followup=self.has_followup,
)

@staticmethod
def fetch(intent_id: str, data: dict) -> Optional[Dialogflow]:
return Dialogflow.selectBy(intent_id=intent_id, data=data).getOne(None)


type CommandsOrCrashesDict = dict[str, str | StringCol]


Expand Down
11 changes: 2 additions & 9 deletions fred/fred.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from nextcord.ext import commands

from . import config
from .cogs import crashes, dialogflow, mediaonly, webhooklistener, welcome, levelling
from .cogs import crashes, mediaonly, webhooklistener, welcome, levelling
from .fred_commands import Commands, FredHelpEmbed
from .libraries import createembed, common

Expand Down Expand Up @@ -102,7 +102,6 @@ def setup_cogs(self):
self.add_cog(webhooklistener.Githook(self))
self.add_cog(mediaonly.MediaOnly(self))
self.add_cog(crashes.Crashes(self))
self.add_cog(dialogflow.DialogFlow(self))
self.add_cog(welcome.Welcome(self))
self.add_cog(levelling.Levelling(self))

Expand All @@ -116,10 +115,6 @@ def MediaOnly(self) -> mediaonly.MediaOnly:
def Crashes(self) -> crashes.Crashes:
return self.get_cog("Crashes") # noqa

@property
def DialogFlow(self) -> dialogflow.DialogFlow:
return self.get_cog("DialogFlow") # noqa

@property
def Welcome(self) -> welcome.Welcome:
return self.get_cog("Welcome") # noqa
Expand Down Expand Up @@ -292,9 +287,7 @@ async def on_message(self, message: nextcord.Message):
self.logger.info("Processing commands")
await self.process_commands(message)
else:
reacted = await self.Crashes.process_message(message)
if not reacted:
await self.DialogFlow.process_message(message)
_reacted = await self.Crashes.process_message(message)
self.logger.info("Finished processing a message", extra=common.message_info(message))

async def repository_query(self, query: str):
Expand Down
3 changes: 1 addition & 2 deletions fred/fred_commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@
from .channels import ChannelCmds
from .crashes import CrashCmds
from .dbcommands import CommandCmds
from .dialogflow import DialogflowCmds
from .experience import EXPCmds
from .help import HelpCmds, FredHelpEmbed
from ..libraries import createembed
from ..libraries.view.mod_picker import ModPicker


class Commands(BotCmds, ChannelCmds, CommandCmds, CrashCmds, DialogflowCmds, EXPCmds, HelpCmds):
class Commands(BotCmds, ChannelCmds, CommandCmds, CrashCmds, EXPCmds, HelpCmds):
@BaseCmds.listener()
async def on_command_error(self, ctx: commands.Context, error):
# We get an error about commands being found when using "runtime" commands, so we have to ignore that
Expand Down
Loading

0 comments on commit 17cf3a6

Please sign in to comment.