C
C
chuvakizit2021-02-01 20:20:17
Python
chuvakizit, 2021-02-01 20:20:17

AIogram bot does not start, how to solve?

Good evening!
When run via the command line, there are no errors, but the bot itself does not process messages.
The token is valid, I took it through Bot Father.
I understand the problem with imports or modules?

bot.py

import asyncio
from aiogram import Bot, types
from aiogram.dispatcher import Dispatcher
from aiogram.utils import executor
from aiogram.types import ReplyKeyboardRemove, \
    ReplyKeyboardMarkup, KeyboardButton, \
    InlineKeyboardMarkup, InlineKeyboardButton
from config import TOKEN

bot = Bot(token=TOKEN)
dp = Dispatcher(bot)


button_repl = KeyboardButton('Сигнал есть!')

signal_kb = ReplyKeyboardMarkup()
signal_kb.add(button_repl)



@dp.message_handler(commands=['start'])
async def process_start_command(message: types.Message):
    await message.reply("Привет!\nЧем могу помочь? /help для просмотра команд!")

@dp.message_handler(commands=['help'])
async def process_start_command(message: types.Message):
    await bot.send_message(msg.from_user.id, '''Команды которые я выполняю:\n/help Помощь,\n /signal Ищет наявность сигнала!''')

@dp.message_handler(commands=['signal'])
async def process_start_command(message: types.Message):
    await message.reply("Есть сигнал?", reply_markup=kb.signal_kb)


The module with the config contains the token.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
C
chuvakizit, 2021-02-01
@chuvakizit

I'm sorry, I forgot about polling!

K
kpa6uu, 2017-07-27
@kpa6uu

8cuJ8D8d9sc.jpg
@
@
nFdepH_jT0U.jpg

T
twobomb, 2017-07-27
@twobomb

Che for such tasks, and stoned variables. I dare to assume that they should be like this. Because there is no such function as $pivo. I'll tell you a secret $kamera, $z and $melta will also give errors.

<?php
define("VICHIT", 1);
define("delen", 2);
define ("ymnozh", 3);
define("slozhe",4);

function mathOperation($arg1, $arg2,$operation)
{
  switch ($operation)
  {
  case VICHIT:
 return bar($arg1, $arg2);
  break;
  
  case delen:
  return $kamera($arg1, $arg2);
  break;
  
  case ymnozh:
  return $z($arg1,$arg2);
  break;
  
  case slozhe;
  return $metla($arg,$arg2);
  break;

  }
  
  
}
echo mathOperation(3,5,1);  // вот тут проблема 

function bar($x,$y)
{
  return ($x-$y);
}

$pivo=bar(12,89);
//echo "$pivo<br>";

function foto($x,$y)
{
  return ($x%$y);
  
}
$kamera=foto(4,5);
//echo "$kamera<br>";

function carga($x, $y) 
{ 
return ($x+$y);

}
$metla=carga(3,15);
//echo "$metla  <br>";

function glaz($h, $r)
{
  return ($h * $r);

}
$z=glaz(45,55);
//echo "$z<br>";
?>

S
SagePtr, 2017-07-27
@SagePtr

Inside the mathOperation function, these variables are not visible.
php.net/manual/en/language.variables.scope.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question