kenken999 commited on
Commit
b2990e4
1 Parent(s): c54cde6
mysite/interpreter/google_chat.py CHANGED
@@ -5,6 +5,54 @@ def convert_newlines_to_google_chat_format(text):
5
  # 改行文字を <br> タグに置き換える
6
  return text.replace('\\n', '\\\n')
7
  #
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  def send_google_chat_card(webhook_url, title, subtitle, link_text, link_url,image_url=None):
9
  headers = {
10
  'Content-Type': 'application/json; charset=UTF-8'
 
5
  # 改行文字を <br> タグに置き換える
6
  return text.replace('\\n', '\\\n')
7
  #
8
+
9
+ def send_google_chat_wav(webhook_url, title, subtitle, link_text, link_url,image_url=None):
10
+ headers = {
11
+ 'Content-Type': 'application/json; charset=UTF-8'
12
+ }
13
+
14
+ subtitle = convert_newlines_to_google_chat_format(subtitle)
15
+
16
+ card_message = {
17
+ "cards": [
18
+ {
19
+ "header": {
20
+ "title": title,
21
+ "imageUrl": image_url,
22
+ "imageStyle": "IMAGE"
23
+ },
24
+ "sections": [
25
+ {
26
+ "widgets": [
27
+ {
28
+ "textParagraph": {
29
+ "text": "音声ファイル"
30
+ }
31
+ },
32
+ {
33
+ "buttons": [
34
+ {
35
+ "textButton": {
36
+ "text": "音声を開く",
37
+ "onClick": {
38
+ "openLink": {
39
+ "url": subtitle
40
+ }
41
+ }
42
+ }
43
+ }
44
+ ]
45
+ },
46
+ ]
47
+ }
48
+ ]
49
+ }
50
+ ]
51
+ }
52
+
53
+
54
+
55
+
56
  def send_google_chat_card(webhook_url, title, subtitle, link_text, link_url,image_url=None):
57
  headers = {
58
  'Content-Type': 'application/json; charset=UTF-8'
routers/webhook.py CHANGED
@@ -13,7 +13,7 @@ from mysite.libs.utilities import validate_signature, no_process_file
13
  #from mysite.database.database import ride,create_ride
14
  from routers.gra_04_database.rides import test_set_lide
15
  from mysite.interpreter.prompt import prompt_genalate,test_prompt
16
- from mysite.interpreter.google_chat import send_google_chat_card,send_google_chat_card_thread
17
  #from mysite.interpreter.interpreter import chat_with_interpreter
18
  from routers.gra_02_openInterpreter.OpenInterpreter import chat_with_interpreter_no_stream
19
  from mysite.appsheet.appsheet import get_senario
@@ -162,8 +162,8 @@ async def webhook(request: Request):
162
  file.write(response.content)
163
 
164
  print(f"Audio saved as {audio_file_path}")
165
- wavurl = "https://kenken999-fastapi-django-main.hf.space/staticfiles/"+audio_file_name
166
- thread_name = send_google_chat_card(webhook_url, "youtube audiofile", wavurl, link_text, link_url,thmbnail)#thread_name)
167
 
168
 
169
 
 
13
  #from mysite.database.database import ride,create_ride
14
  from routers.gra_04_database.rides import test_set_lide
15
  from mysite.interpreter.prompt import prompt_genalate,test_prompt
16
+ from mysite.interpreter.google_chat import send_google_chat_card,send_google_chat_card_thread,send_google_chat_wav
17
  #from mysite.interpreter.interpreter import chat_with_interpreter
18
  from routers.gra_02_openInterpreter.OpenInterpreter import chat_with_interpreter_no_stream
19
  from mysite.appsheet.appsheet import get_senario
 
162
  file.write(response.content)
163
 
164
  print(f"Audio saved as {audio_file_path}")
165
+ wavurl = "https://kenken999-fastapi-django-main.hf.space/static/"+audio_file_name
166
+ thread_name = send_google_chat_wav(webhook_url, "youtube audiofile", wavurl, link_text, link_url,thmbnail)#thread_name)
167
 
168
 
169
 
staticfiles/audio_20240707054625.wav ADDED
Binary file (264 kB). View file
 
text.txt CHANGED
@@ -1 +1 @@
1
- 【リッチメニュー】本日の金価格
 
1
+ 本日の金価格は、13,143円です。