forked from mixer/beam-client-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
26 lines (19 loc) · 676 Bytes
/
example.py
File metadata and controls
26 lines (19 loc) · 676 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""
Example chat bot that monitors incoming messages. responds to !ping command
"""
from tornado.ioloop import IOLoop
from chatty import create
import config
import ChatEventHandler
def _handle_chat(data):
chatevents.formatting(data)
if __name__ == "__main__":
chat = create(config)
chatevents = ChatEventHandler.Handler(config, chat)
# Tell chat to authenticate with the beam server. It'll throw
# a chatty.errors.NotAuthenticatedError if it fails.
chat.authenticate()
# Listen for incoming messages. When they come in, just print them.
chat.on("message", _handle_chat)
# Start the tornado event loop.
IOLoop.instance().start()