You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
Python
44 lines
1.1 KiB
Python
4 years ago
|
###################################
|
||
|
# WHAT IS IN THIS EXAMPLE?
|
||
|
#
|
||
|
# This bot listens to two channels for a special text message. When
|
||
|
# it sees this message, it replies in the same channel with a response.
|
||
|
# This also shows sending and receiving unicode characters.
|
||
|
###################################
|
||
|
|
||
|
import asyncio
|
||
|
import logging
|
||
|
import os
|
||
|
|
||
|
import pykeybasebot.types.chat1 as chat1
|
||
|
from pykeybasebot import Bot
|
||
|
|
||
|
logging.basicConfig(level=logging.DEBUG)
|
||
|
|
||
|
|
||
|
class Handler:
|
||
|
async def __call__(self, bot, event):
|
||
|
if event.msg.content.type_name != chat1.MessageTypeStrings.TEXT.value:
|
||
|
return
|
||
|
if event.msg.content.text.body == "🌴ping🌴":
|
||
|
channel = event.msg.channel
|
||
|
await bot.chat.send(channel, "🍹PONG!🍹")
|
||
|
|
||
|
|
||
|
listen_options = {
|
||
|
"filter-channels": [
|
||
|
{"name": "spoonbot,androiddrew"},
|
||
|
# {
|
||
|
# "name": "runcibleio",
|
||
|
# "topic_name": "general",
|
||
|
# "members_type": "team",
|
||
|
# },
|
||
|
]
|
||
|
}
|
||
|
|
||
|
bot = Bot(
|
||
|
username="spoonbot", paperkey=os.environ["KEYBASE_PAPERKEY"], handler=Handler()
|
||
|
)
|
||
|
|
||
|
asyncio.run(bot.start(listen_options))
|