Skip to content

Commit a7d94ad

Browse files
committed
Framework Hackathon Update
1 parent 365620a commit a7d94ad

File tree

1,204 files changed

+114188
-47147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,204 files changed

+114188
-47147
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ yarn-error.log*
7171
.vercel
7272
*.tsbuildinfo
7373
next-env.d.ts
74+
coverage/
75+
/coverage
7476

7577
# Misc
7678
*.log

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -212,4 +212,3 @@ This project is licensed under the MIT License - see the LICENSE file for detail
212212
213213
Contributions are highly encouraged! Please consult the CONTRIBUTING.md document for details on our code of conduct, and
214214
the process for submitting pull requests to the project.
215-

bot/.env.example

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Telegram Bot Settings
22
# Bmeme stage
3-
BOT_TOKEN="BOT_TOKEN"
3+
BOT_TOKEN="bot_key"
44
SUPPORT_URL="dex.guru"
55
RATE_LIMIT=0.5
66
DEBUG=True
@@ -10,14 +10,14 @@ WEBHOOK_HOST="0.0.0.0" # use "localhost" if not using Docker
1010
WEBHOOK_PORT=8080
1111
WEBHOOK_BASE_URL="https://example.com"
1212
WEBHOOK_PATH="/webhook"
13-
WEBHOOK_SECRET="Pl7U9AJUFb2"
13+
WEBHOOK_SECRET="secret"
1414

1515

16-
FLOW_API="http://flow-api"
16+
FLOW_API="http://localhost:8000"
1717
FLOW_SYS_KEY="secret"
1818

19-
ENGINE_ADMIN_PREFIX="http://engine"
20-
ENGINE_URL="http://engine/engine-rest"
19+
ENGINE_ADMIN_PREFIX="http://localhost:8000"
20+
ENGINE_URL="http://localhost:8000/engine-rest"
2121
ENGINE_USERNAME="demo"
2222
ENGINE_PASSWORD="demo"
2323
ENGINE_USERS_GROUP_ID="camunda-admin"
@@ -37,3 +37,5 @@ PROMETHEUS_PORT=9090
3737
GRAFANA_PORT=3000
3838
GRAFANA_ADMIN_USER="admin"
3939
GRAFANA_ADMIN_PASSWORD="admin"
40+
41+
WEB3_PROVIDER="https://rpc.gurunetwork.ai/archive/261"

bot/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,6 @@ dmypy.json
135135

136136
logs/
137137

138+
Pipfile.lock
139+
Pipfile
138140

bot/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.10-alpine3.18
1+
FROM docker-registry.dexguru.biz/dex.guru/utils/python:3.10-alpine3.18
22

33
WORKDIR /usr/src/app
44

@@ -23,4 +23,4 @@ RUN adduser -D appuser \
2323

2424
USER appuser
2525

26-
CMD ["python", "-m", "bot"]
26+
CMD [ "python", "./bot_server/__main__.py" ]

bot/README.md

-234
This file was deleted.

bot/bot_server/__main__.py

+23-15
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import Sequence
66

77
import httpx
8+
89
# import sentry_sdk
910
import uvloop
1011

@@ -17,7 +18,10 @@
1718
from bot_server.core.loader import app, bot, dp
1819
from bot_server.handlers import get_handlers_router
1920
from bot_server.handlers.metrics import MetricsView
20-
from bot_server.keyboards.default_commands import remove_default_commands, set_default_commands
21+
from bot_server.keyboards.default_commands import (
22+
remove_default_commands,
23+
set_default_commands,
24+
)
2125
from bot_server.keyboards.inline.task import task_keyboard
2226
from bot_server.middlewares import register_middlewares
2327
from bot_server.middlewares.prometheus import prometheus_middleware_factory
@@ -36,7 +40,7 @@
3640

3741

3842
async def fetch_camunda_tasks() -> Sequence[dict]:
39-
pass # till user
43+
pass # till user
4044
# async with httpx.AsyncHTTPTransport() as transport:
4145
#
4246
# camunda_client = CamundaEngineClient(
@@ -68,20 +72,23 @@ async def fetch_camunda_task_and_send_notification() -> dict:
6872
if tasks:
6973
tasks_dict = defaultdict(list)
7074
for task in tasks:
71-
if task['telegram_user_id']:
72-
tasks_dict[task['telegram_user_id']].append(task)
75+
if task["telegram_user_id"]:
76+
tasks_dict[task["telegram_user_id"]].append(task)
7377

7478
for user_id, tasks in tasks_dict.items():
75-
await bot.send_message(chat_id=user_id, text="Tasks available in tasklist:",
76-
reply_markup=task_keyboard(tasks))
77-
79+
await bot.send_message(
80+
chat_id=user_id,
81+
text="Tasks available in tasklist:",
82+
reply_markup=task_keyboard(tasks),
83+
)
7884

79-
async def check_for_camunda_tasks(dispatcher):
80-
while True:
81-
# Assume you have a list of user IDs to poll tasks for
82-
await fetch_camunda_task_and_send_notification()
8385

84-
await asyncio.sleep(300) # Check every 60 seconds, adjust as needed
86+
# async def check_for_camunda_tasks(dispatcher):
87+
# while True:
88+
# # Assume you have a list of user IDs to poll tasks for
89+
# await fetch_camunda_task_and_send_notification()
90+
#
91+
# await asyncio.sleep(300) # Check every 60 seconds, adjust as needed
8592

8693

8794
async def on_startup() -> None:
@@ -96,7 +103,7 @@ async def on_startup() -> None:
96103
app.router.add_route("GET", "/metrics", MetricsView)
97104

98105
await set_default_commands(bot)
99-
asyncio.create_task(check_for_camunda_tasks(dp)) # Start the polling task
106+
# asyncio.create_task(check_for_camunda_tasks(dp)) # Start the polling task
100107

101108
bot_info = await bot.get_me()
102109

@@ -122,10 +129,11 @@ async def on_shutdown() -> None:
122129

123130
await remove_default_commands(bot)
124131

132+
await bot.delete_webhook()
133+
await bot.close()
125134
await dp.storage.close()
126135
await dp.fsm.storage.close()
127136

128-
await bot.delete_webhook()
129137
await bot.session.close()
130138

131139
logger.info("bot stopped")
@@ -179,7 +187,7 @@ async def handle_mention_message(message: Message):
179187
"message_id": message.message_id,
180188
"from_user": message.from_user.id,
181189
"text": message.text,
182-
"date": message.date.isoformat()
190+
"date": message.date.isoformat(),
183191
}
184192
await message.answer("Mention saved!")
185193

0 commit comments

Comments
 (0)