message passing code
This commit is contained in:
parent
cf610af441
commit
a212804b8d
|
|
@ -48,6 +48,33 @@ class DiscordBotPlugin(PHALPlugin):
|
|||
LOG.info(f"Admin is {admin.name}")
|
||||
await admin.send("I'm now online")
|
||||
|
||||
# Discord event: Process incoming messages
|
||||
@this.bot.event
|
||||
async def on_message(message):
|
||||
if message.author == bot.user:
|
||||
return
|
||||
|
||||
await bot.process_commands(message)
|
||||
admin = await get_discord_user_by_id(self.config.get("admin_id"))
|
||||
|
||||
if message.author == admin:
|
||||
if message.content.lower().startswith("tell mycroft"):
|
||||
# The message starts with "tell mycroft"
|
||||
# Implement the action you want to take in response to this here.
|
||||
# For example, you can extract the command from the message and respond accordingly.
|
||||
command = message.content[len("tell mycroft"):].strip() # Remove "tell mycroft" and strip any leading/trailing spaces.
|
||||
# Now, you can execute the command or respond accordingly based on the extracted command.
|
||||
self.bus.emit(
|
||||
Message(
|
||||
"recognizer_loop:utterance",
|
||||
{
|
||||
'utterances': [command],
|
||||
'lang': 'en-us'
|
||||
}
|
||||
)
|
||||
)
|
||||
await message.channel.send(f"Telling mycroft {command}")
|
||||
|
||||
QUEUE_POLL_INTERVAL = 0.2
|
||||
@tasks.loop(seconds=QUEUE_POLL_INTERVAL)
|
||||
async def myLoop():
|
||||
|
|
|
|||
Loading…
Reference in New Issue