Skip to content

Commit

Permalink
fixed issue with command gcode
Browse files Browse the repository at this point in the history
  • Loading branch information
ksergey committed Jan 6, 2024
1 parent f0e64c8 commit 3134f02
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions app/handlers/emergency_stop.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

from aiogram import Bot, Dispatcher, Router
from aiogram import Router
from aiogram.types import Message, CallbackQuery
from aiogram.filters import Command
from aiogram.filters.callback_data import CallbackData
Expand All @@ -27,7 +27,7 @@ def make_confirmation_keyboard() -> InlineKeyboardMarkup:
return builder.as_markup()

@router.callback_query(EmergencyStopCallback.filter())
async def callback_emergency_stop(callback: CallbackQuery, callback_data: EmergencyStopCallback, bot: Bot, moonraker: Moonraker):
async def callback_emergency_stop(callback: CallbackQuery, callback_data: EmergencyStopCallback, moonraker: Moonraker):
await callback.answer()

message = callback.message.reply_to_message
Expand All @@ -43,5 +43,5 @@ async def callback_emergency_stop(callback: CallbackQuery, callback_data: Emerge
await message.edit_text(f'\N{Heavy Ballot X} error: {ex}')

@router.message(Command('emergency_stop'))
async def handler_command_emergency_stop(message: Message, bot: Bot, dispatcher: Dispatcher, moonraker: Moonraker):
async def handler_command_emergency_stop(message: Message, moonraker: Moonraker):
await message.reply('are you shure?', reply_markup=make_confirmation_keyboard())
8 changes: 4 additions & 4 deletions app/handlers/gcode.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import logging

from aiogram import Bot, Dispatcher, Router
from aiogram import Router
from aiogram.types import Message
from aiogram.filters import Command
from aiogram.filters import Command, CommandObject

from app.moonraker import Moonraker

logger = logging.getLogger(__name__)
router = Router()

@router.message(Command('gcode'))
async def handler_command_gcode(message: Message, bot: Bot, dispatcher: Dispatcher, moonraker: Moonraker):
async def handler_command_gcode(message: Message, command: CommandObject, moonraker: Moonraker):
notification_message = await message.answer('\N{SLEEPING SYMBOL}...')
try:
script = message.get_args()
script = command.args or ''
if script == '':
raise RuntimeError('empty script')
await moonraker.gcode_script(script)
Expand Down
4 changes: 2 additions & 2 deletions app/handlers/last.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

from aiogram import Bot, Dispatcher, Router
from aiogram import Router
from aiogram.types import Message, BufferedInputFile
from aiogram.filters import Command

Expand All @@ -11,7 +11,7 @@
router = Router()

@router.message(Command('last'))
async def handler_command_last(message: Message, bot: Bot, dispatcher: Dispatcher, moonraker: Moonraker):
async def handler_command_last(message: Message, moonraker: Moonraker):
notification_message = await message.answer('\N{SLEEPING SYMBOL}...')
try:
data = await moonraker.history_list(limit=1, order='desc')
Expand Down
4 changes: 2 additions & 2 deletions app/handlers/status.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

from aiogram import Bot, Dispatcher, Router
from aiogram import Router
from aiogram.types import Message, BufferedInputFile
from aiogram.filters import Command

Expand All @@ -12,7 +12,7 @@
router = Router()

@router.message(Command('status'))
async def handler_command_status(message: Message, bot: Bot, dispatcher: Dispatcher, moonraker: Moonraker):
async def handler_command_status(message: Message, moonraker: Moonraker):
notification_message = await message.answer('\N{SLEEPING SYMBOL}...')
try:
if not moonraker.online():
Expand Down
4 changes: 2 additions & 2 deletions app/handlers/toolbox.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

from aiogram import Bot, Dispatcher, Router
from aiogram import Router
from aiogram.types import Message, CallbackQuery
from aiogram.filters import Command
from aiogram.filters.callback_data import CallbackData
Expand Down Expand Up @@ -55,7 +55,7 @@ def relative_before(gcode: str) -> str:
return builder.as_markup(resize_keyboard=True)

@router.callback_query(ToolboxCallback.filter())
async def callback_toolbox(callback: CallbackQuery, callback_data: ToolboxCallback, bot: Bot, moonraker: Moonraker):
async def callback_toolbox(callback: CallbackQuery, callback_data: ToolboxCallback, moonraker: Moonraker):
await moonraker.gcode_script(callback_data.gcode)
await callback.answer(text=f'done')

Expand Down
4 changes: 2 additions & 2 deletions app/handlers/video.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

from aiogram import Bot, Dispatcher, Router
from aiogram import Router
from aiogram.types import Message, BufferedInputFile
from aiogram.filters import Command

Expand All @@ -10,7 +10,7 @@
router = Router()

@router.message(Command('video'))
async def handler_command_video(message: Message, bot: Bot, dispatcher: Dispatcher):
async def handler_command_video(message: Message):
notification_message = await message.answer('\N{SLEEPING SYMBOL}...')
try:
video = await get_webcam_video()
Expand Down

0 comments on commit 3134f02

Please sign in to comment.