async def on_message(self, message): if message.author.bot: # ボットのメッセージをハネる return if message.channel.id == 663043626418569256: talk_client = pya3rt.TalkClient(os.environ['TALK_API_KEY']) content = talk_client.talk(message.content)['results'][0]['reply'] await message.channel.send(content) # 返信メッセージを送信
async def on_message(message): await bot.process_commands(message) # we do not want the bot to reply to itself if message.author == bot.user: return if bot.user.mentioned_in(message): #メンションに返信 API_KEY = "jPOnGtEHD6pSi5Tcl81r8wy53vviHL55" client = pya3rt.TalkClient(API_KEY) botid = "<@" + bot.user.id + ">" send = re.sub(botid, "", message.content) #mention文字列を取り除く resp = client.talk(send) # print(send) if resp["status"] == 0: reply = resp["results"][0]["reply"] await bot.send_message(message.channel, reply) if message.content.startswith('!hello'): msg = 'Hello {0.author.mention}'.format(message) await bot.send_message(message.channel, msg) if message.content.startswith('!close'): await bot.close() if message.content.startswith('!delete'): def is_me(m): return m.author == bot.user deleted = await bot.purge_from(message.channel, limit=100, check=is_me) await bot.send_message(message.channel, 'Deleted {} message(s)'.format(len(deleted))) else: return
def default_func(message): log_output(message) client = pya3rt.TalkClient(slackbot_settings.A3RT_API_KEY) try: message.reply(str((client.talk(str(message._body['text'])))["results"][0]["reply"])) except Exception as e: message.reply("ちょっと何言ってるかわかりません")
def message_event(event): #reply = event.massage.text client = pya3rt.TalkClient(talk_api) response = client.talk(event.message.text) reply = response['result'][0]['reply'] line_bot_api.reply_message(event.reply_token, TextSendMessage(text=reply))
def my_default_handler(message): key = os.environ["A3RT_TOKEN"] client = pya3rt.TalkClient(key) rep = client.talk(message.body['text']) if rep['message'] == "ok": rep = rep['results'][0]['reply'] message.reply(rep) else: message.reply("seyana") message.react("apare")
def message_event(event): # オウム返し # reply = event.message.text # 受信したメーッセージを取得 # 雑談Bot client = pya3rt.TalkClient(talk_api) response = client.talk(event.message.text) reply = response['results'][0]['reply'] line_bot_api.reply_message(event.reply_token, TextSendMessage(text=reply))
def get_reply_message(text): client = pya3rt.TalkClient(const.A3RT_TALK_API_KEY) res = client.talk(text) print(res) # 正常終了以外はデフォルトメッセージを返却する if res['status'] != 0: return const.MESSAGE_REPLY_DEFAULT reply = res['results'][0]['reply'] return reply
def talkapi(text): apikey = os.environ["TALK_API_KEY"] client = pya3rt.TalkClient(apikey) response = client.talk(text) msg = response['results'][0]['reply'] snd = Sender( name="令和市公民館跡地のハムスター", icon_url= "https://reiwacity-linebot.s3-ap-northeast-1.amazonaws.com/reiwa_hamstar.jpg" ) text_message = TextSendMessage(msg, sender=snd) return text_message
def handle_message(event): # -*- coding: utf-8 -*- import pya3rt apikey = "DZZEqN4NXwlVu2ONNpRb0N7aMAu8lx2S" client = pya3rt.TalkClient(apikey) word = event.message.text res = client.talk(word) #print(res['results'][0]['reply']) line_bot_api.reply_message( event.reply_token, TextSendMessage(text=res['results'][0]['reply']))
def talkapi_response(push_text): """ Return reply message from A3RT/TalkAPI. :param push_text: push message text :type push_text: str :returns: talkapi_reply :rtype: str """ talkapi_client = pya3rt.TalkClient(os.environ.get('A3RT_TALKAPI_APIKEY')) talkapi_response = talkapi_client.talk(push_text) talkapi_reply = ((talkapi_response['results'])[0])['reply'] return talkapi_reply
def talkA3rt(message): apikey = '' client = pya3rt.TalkClient(apikey) api_response = client.talk(message.body['text']) # レスポンスがokの時返事を返す if api_response['message'] == 'ok': reply_message = api_response['results'][0]['reply'] message.reply(jaconv.hira2kata(reply_message) + '…ロボ') # 普通の返事 # message.reply(reply_message) # APIエラーの時はmessageを返す else: message.reply('エラー、ウマク返事ガデキマセン [ERROR:' + api_response['message'] + ']')
def talk_ai(word): if word == "ごりら": return 'I AM GORILLA' elif word[0] == 'Q': search_word = word[1:] url = 'https://www.google.co.jp/search' response = requests.get(url, params={'q': search_word}) return response.url else: apikey = 'DZZgNzc1RdpkDzIvzfq6ZGKJCZ1QH4LL' client = pya3rt.TalkClient(apikey) reply_message = client.talk(word) return reply_message['results'][0]['reply']
def chat(text): apikey = "8auKLi5BoSFKoBkIPPgji1bNwD3MukyQ" client = pya3rt.TalkClient(apikey) in_t = "[IN]" out_t = "[OUT]" #f = open('zatsudan.log','a+') AI = client.talk(text) f.write(in_t + text) if AI['message'] != 'ok': #okのときmessageが返ってくる、それ以外は何らかのエラー #f.write("[" + AI['message'] + "]\n") print("OUT:" + "はい?") return "はい?" else: #f.write(out_t+AI['results'][0]['reply']+"\n") print("OUT:", AI['results'][0]['reply']) return AI['results'][0]['reply']
# -*- coding: utf-8 -*- import pya3rt apikey = "{YOUR_API_KEY}" client = pya3rt.TalkClient(apikey) print(client.talk("おはよう"))
from PIL import Image from io import BytesIO sys.path.append('./bot') REPLY_ENDPOINT = 'https://api.line.me/v2/bot/message/reply' ACCESS_TOKEN = qw+7CBSbMVa5DOl23LfTZRa/BigoU/aHE5zCszPCOr0FQxwOj00GiPwKWGI33ToMigcZCjAXl4AwH60QcDbFYjlT9g33kqUyA34mXjITjtRn/T10Y27uN1pv/rkDz7Ib5GSousReprKW6IG4U5kE9QdB04t89/1O/w1cDnyilFU= HEADER = { "Content-Type": "application/json", "Authorization": "Bearer " + ACCESS_TOKEN } lINE_BOT_API = LineBotApi(ACCESS_TOKEN) # recuitAPI recuitapikey = "c3a47a8a338c4530" client = pya3rt.TalkClient(recuitapikey) # docomoAPI docomoapikey = '6f64383237754e464474526250304832477368362f7451316936354f4451667a6e4a715534743037306832' # Get API_Path def __build_url(name, version='v1'): return __api_path.format({'version': version, 'name': name}) __api_path = 'https://api.apigw.smt.docomo.ne.jp/imageRecognition/{0[version]}/{0[name]}' def index(request): return HttpResponse("This is bot api.") # Reply text
def talk(call): apikey = os.environ['TALK_API'] client = pya3rt.TalkClient(apikey) reply = client.talk(call) return reply['results'][0]['reply']
import pya3rt import requests import base64 import json import uuid import os app = Flask(__name__) channel_secret = os.getenv('LINE_CHANNEL_SECRET', None) channel_access_token = os.getenv('LINE_CHANNEL_ACCESS_TOKEN', None) line_bot_api = LineBotApi(channel_access_token) handler = WebhookHandler(channel_secret) talk_api = os.getenv('talk_api', None) talk = pya3rt.TalkClient(talk_api) VISION_API = os.getenv('VISION_API', None) GOOGLE_CLOUD_VISION_API_URL = 'https://vision.googleapis.com/v1/images:annotate?key=' # APIを呼び、認識結果をjson型で返す def request_cloud_vison_api(image_base64): api_url = GOOGLE_CLOUD_VISION_API_URL + VISION_API req_body = json.dumps({ 'requests': [{ 'image': { 'content': image_base64.decode('utf-8') # jsonに変換するためにstring型に変換する }, 'features': [{
def send_message(message): apikey = "A3RT TalkAPI Token Here" client = pya3rt.TalkClient(apikey) reply_message = client.talk(message) return reply_message['results'][0]['reply']
from flask import Flask, request, abort from linebot import LineBotApi, WebhookHandler from linebot.exceptions import InvalidSignatureError from linebot.models import MessageEvent, TextMessage, TextSendMessage app = Flask(__name__) with open('keys.txt', 'r') as f: keys_list = f.readlines() line_token = keys_list[0].replace('\n','') line_secret = keys_list[1].replace('\n','') a3rt_key = keys_list[2].replace('\n','') line_bot_api = LineBotApi(line_token) handler = WebhookHandler(line_secret) client = pya3rt.TalkClient(a3rt_key) @app.route("/callback", methods=['POST']) def callback(): # get X-Line-Signature header value signature = request.headers['X-Line-Signature'] # get request body as text body = request.get_data(as_text=True) app.logger.info("Request body: " + body) # handle webhook body try: handler.handle(body, signature) except InvalidSignatureError: abort(400)
def send_message(message): apikey = "DZZO6OWV5Au3DH7u9cdHVtZMfbPh4gHx" client = pya3rt.TalkClient(apikey) reply_message = client.talk(message) return reply_message['results'][0]['reply']
from linebot.models import TextMessage from linebot.models import TextSendMessage from .functions import get_config from .functions import get_logging_config from .functions import is_webhook from .functions import remove_emoji config.fileConfig(get_logging_config()) logger = getLogger() app = Flask(__name__) app_config = get_config() client = pya3rt.TalkClient(app_config["A3RT"]["ApiKey"]) line_bot_api = LineBotApi(app_config["LineConfig"]["AccessToken"]) handler = WebhookHandler(app_config["LineConfig"]["ChannelSecret"]) @app.route("/", methods=['POST']) def callback(): # get X-Line-Signature header value signature = request.headers['X-Line-Signature'] # get request body as text body = request.get_data(as_text=True) app.logger.info("Request body: " + body) # handle webhook body try:
def talkapi_response(push_text): talkapi_client = pya3rt.TalkClient(A3RT_TALKAPI_APIKEY) talkapi_response = talkapi_client.talk(push_text) return ((talkapi_response['results'])[0])['reply']
def getChatWithA3rt(txt): key ='***' client = pya3rt.TalkClient(key) reply_message = client.talk(txt) return reply_message['results'][0]['reply']
def talkapi_response(text): apikey = "DZZM8VCuOFEqXu8VG4XbVICGtI1S6gVD" client = pya3rt.TalkClient(apikey) response = client.talk(text) return ((response['results'])[0])['reply']
def talk_ai(word): apikey = "DZZt3A2mEKqmPw85C0vSv2QIVbm8pWma" client = pya3rt.TalkClient(apikey) replay_message = client.talk(word) return replay_message['results'][0]['reply']
def talk_ai(word): apikey = "DZZ8Iwyo6fo6lY7JVUWSqgqrgze4IbBz" client = pya3rt.TalkClient(apikey) reply_message = client.talk(word) return reply_message['results'][0]['reply']
def talk_ai(word): apikey = "DZZMTG52PuQHcRv4a8Q3z2EAYfc2C3Nc" client = pya3rt.TalkClient(apikey) reply_message = client.talk(word) return reply_message['results'][0]['reply']
def talkapi_response(text): apikey = "DZZTN8HTduABGoAd8GPaM3QCvapddGU7" client = pya3rt.TalkClient(apikey) response = client.talk(text) return ((response['results'])[0])['reply']
from linebot import ( LineBotApi, WebhookHandler ) from linebot.exceptions import ( InvalidSignatureError ) from linebot.models import ( MessageEvent, TextMessage, TextSendMessage, TemplateSendMessage, MessageAction, URIAction, PostbackAction, CarouselTemplate, CarouselColumn ) from janome.tokenizer import Tokenizer talk_apikey = "DZZyF7nPhIQoS87LCI7vuIqfdeSElSB8" client = pya3rt.TalkClient(talk_apikey) sample_members = { "揚出 剛史":["あげいでたけし", "male", "47", "医師", "対話による体調診断をおこないます。", "15", "https://www.google.com/"], "川内谷 茜音":["かわうちやあかね", "female", "51", "主婦", "料理をしにいきます。", "3", "https://www.yahoo.co.jp/"], "谷合 沙樹":["たにあいさき", "unknown", "private", "PM", "PG講座を行います。", "5", "https://www.msn.com/ja-jp"], "旭爪 昌典":["ひのつめまさのり", "male", "60", "リタイア", "おはなし相手になります。", "1", "https://www.bing.com/"], "乙幡 涼香":["おとはたすずか", "female", "41", "シェフ", "料理教室の講師を請け負います。", "33", "https://www.yahoo.co.jp/"] } class talker: def __init__(self, parent=None): pass @staticmethod def default_talk(push):
def talk_ai(word): apikey = 'DZZejeeQuT5pnkCbLZtaLHUg2a5ftDhL' client = pya3rt.TalkClient(apikey) client_talk = client.talk(word) return client_talk['results'][0]['reply']