Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F626142
main.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
main.py
View Options
import
sys
import
time
import
telepot
#fetching our BOT_TOKEN
BOT_TOKEN
=
sys
.
argv
[
1
]
def
chat_handler
(
msg
):
content_type
,
chat_type
,
chat_id
=
telepot
.
glance
(
msg
)
if
content_type
==
'text'
:
if
"hendrik"
in
(
msg
[
'text'
]
.
lower
()):
bot
.
sendMessage
(
chat_id
,
'Who the fuck is Hendrik?'
,
reply_to_message_id
=
msg
[
'message_id'
])
print
"Trigger Phrase Detected:
\n
Message Text: {}"
.
format
(
msg
[
'text'
])
def
edit_handler
(
msg
):
content_type
,
chat_type
,
chat_id
=
telepot
.
glance
(
msg
)
if
content_type
==
'text'
:
if
"hendrik"
in
(
msg
[
'text'
]
.
lower
()):
bot
.
sendMessage
(
chat_id
,
'Your sneaky edits do not work on me. Who the fuck is Hendrik?'
,
reply_to_message_id
=
msg
[
'message_id'
])
print
"Trigger Phrase Detected (EDITED MESSAGE):
\n
Message Text: {}
\n
Sender: {}
\n
"
.
format
(
msg
[
'text'
],
msg
[
'from'
])
#make our bot and feed it the token
bot
=
telepot
.
Bot
(
BOT_TOKEN
)
#fetch messages and keep script looped
bot
.
message_loop
({
'chat'
:
chat_handler
,
'edited_chat'
:
edit_handler
},
run_forever
=
"Bot Running..."
)
File Metadata
Details
Attached
Mime Type
text/x-script.python
Expires
Sun, Nov 15, 12:22 AM (1 d, 15 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
134197
Default Alt Text
main.py (1 KB)
Attached To
Mode
R41 JanBot
Attached
Detach File
Event Timeline