-
Notifications
You must be signed in to change notification settings - Fork 4
/
example.py
43 lines (36 loc) · 1.01 KB
/
example.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""
This bot is simple: it sits in the room and responds to two commands:
.dude and .sweet
Example output:
d00kiesh0es: .sweet
bot: dude
d00kiesh0es: .dude
bot: sweet
"""
from calamari.engine import CalamariEngine
from calamari.interfaces import CalamariXMPP, CalamariIRC
# Instantiate and configure the bot engine
bot = CalamariEngine(__name__)
# Instantiate all the interfaces
xmpp_interface = CalamariXMPP( "user@chat.server.com/jid"
"password", "room_name", 'bot_nick' )
# Last 3 arguments are optional
irc_interface = CalamariIRC( 'irc_server.example.com',
6697, 'IRC_CHANNEL', 'bot_nick', use_ssl=True, # Use SSL
username='IRC_USERNAME', password='IRC_PASSWORD' )
# Register all the interfaces
bot.register_interface( xmpp_interface )
bot.register_interface( irc_interface )
@bot.command( "dude" )
def dude( msg, user ):
"""
sweeeet
"""
return "sweet"
@bot.command( "sweet" )
def sweet( msg, user ):
"""
duuuuuude
"""
return "dude"
bot.run()