Example #1
0
File: echo.py Project: ixtel/aiotg
import os
from aiotg import TgBot

bot = TgBot(os.environ["API_TOKEN"])

@bot.command(r"/echo (.+)")
def echo(chat, match):
    return chat.reply(match.group(1))

if __name__ == '__main__':
    bot.run()
Example #2
0
            latitude=content["resultValues"]["latitude"],
            longitude=content["resultValues"]["longitude"])
    except KeyError:
        logger.warn("The stop does not exists")


def parse_stop_response(content):
    if "arrives" not in content:
        return "No encuentro la parada"

    buses = content["arrives"]
    for bus in buses:
        if bus["busTimeLeft"] == 999999:
            bus["busTimeLeft"] = 20
        else:
            bus["busTimeLeft"] = bus["busTimeLeft"] / 60

    text = ""
    for bus in buses:
        text += "{:4s} {:15s} {:3d}m\n".format(bus["lineId"],
                                               bus["destination"],
                                               int(bus["busTimeLeft"]))
    return text


if __name__ == '__main__':
    bot.run()
    # arrive_stop("", "1000")
    # location_stop("", "1000")
    # get_stops_from_x_y({'latitude': 40.449461, 'longitude': -3.677823})