本文整理汇总了Python中bot.Bot.get_sentence方法的典型用法代码示例。如果您正苦于以下问题:Python Bot.get_sentence方法的具体用法?Python Bot.get_sentence怎么用?Python Bot.get_sentence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bot.Bot
的用法示例。
在下文中一共展示了Bot.get_sentence方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SlackClient
# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import get_sentence [as 别名]
bot.add_sentence(line.strip())
token = "GET YOUR OWN TOKEN" # found at https://api.slack.com/web#authentication
sc = SlackClient(token)
fh = open('history.txt', 'a')
if sc.rtm_connect():
while True:
evts = sc.rtm_read()
for evt in evts:
if evt["type"] == "message" and "text" in evt:
if evt["text"].lower().startswith("hey bot"):
sc.api_call("chat.postMessage",
channel="#general",
text=bot.get_sentence(),
username="august_bot",
icon_emoji=":robot_face:")
else:
if "subtype" not in evt or ("subtype" in evt and evt["subtype"] != "bot_message"):
fh.write(evt['text']+'\n')
bot.add_sentence(evt["text"])
time.sleep(1)
else:
print("Connection Failed, invalid token?")
fh.close()
示例2: Bot
# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import get_sentence [as 别名]
import time
from slackclient import SlackClient
from bot import Bot
bot = Bot()
token = "GET YOUR OWN TOKEN" # found at https://api.slack.com/web#authentication
sc = SlackClient(token)
if sc.rtm_connect():
while True:
evts = sc.rtm_read()
for evt in evts:
if evt['type'] == 'message' and 'text' in evt:
if evt['text'].lower().startswith('hey bot'):
sc.api_call("chat.postMessage", channel="#general", text=bot.get_sentence(), username='august_bot', icon_emoji=':robot_face:')
else:
if 'subtype' not in evt or ('subtype' in evt and evt['subtype'] != 'bot_message'):
bot.add_sentence(evt['text'])
time.sleep(1)
else:
print("Connection Failed, invalid token?")