import urllib.request import vobject import locale from datetime import datetime from time import sleep from telegram import Bot, ParseMode from telegram.ext import Updater, CommandHandler import subprocess from threading import Thread locale.setlocale(locale.LC_TIME, 'es_ES.utf8') # para tener 'lunes' en lugar de 'Monday' tkn = '==123456789:tg-token-USER-BOT==' bot = Bot(token=tkn) bot.chat_id = '==998877665==' #user-chatId myLocalIP = '==192.168.X.X==' weekendOut = False def tg_bus(bot, update): try: viaje, dSale, hSale, hLlega = bus_ics('download.ics') message(bold(viaje) + from_to(dSale, hSale, hLlega)) except (IndexError, ValueError): update.message.reply_text("uso: /bus") def tg_uni(bot, update): try: url = '==https://calendar.google.com/calendar/ical/A-URL-FROM-GOOGLE-CALENDAR/basic.ics=='
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # to log output, RUN WITH: # nohup python3 pinger.py >> pingeroutput.log & from bs4 import BeautifulSoup import urllib.request from time import sleep from datetime import datetime from telegram import Bot oclock = 1 bot = Bot(token='123456789:mytelegramto-ken') bot.chat_id = '001122334' def message(text): bot.send_message(chat_id=bot.chat_id, text=text) while True: r = urllib.request.Request("https://websi.te", headers={'Cookie': "yourSession=c0ok1eV4lu3"}) html = urllib.request.urlopen(r).read() soup = BeautifulSoup(html, 'html.parser') # parse HTML to find course content sections = soup.find_all('span', {'class': 'instancename'}) ''' here i'm checking if there's more than 4 sections in a moodle site,
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # EJECUTAR CON: # nohup python3 admin_qtvmc.py >> admin_qtvmc.log & import urllib.request import vobject from datetime import datetime from quetalvamichico_bot import bus_ics, from_to, message, bold from telegram import Bot, ParseMode from telegram.ext import Updater, CommandHandler, MessageHandler, Filters tkn = '==123456789:tg-token-ADMIN-BOT==' bot = Bot(token=tkn) bot.chat_id = '==001122334==' #admin-chatId def doc_handler(bot, update): if update.effective_message.document.mime_type == 'text/calendar': # si se envían varios archivos a la vez, se queda con el último file = bot.getFile(update.effective_message.document.file_id) file.download('download.ics') viaje, dSale, hSale, hLlega = bus_ics('download.ics') message_check(bold(viaje) + from_to(dSale, hSale, hLlega)) def message_check(text): bot.send_message(chat_id=bot.chat_id, text=text, parse_mode=ParseMode.MARKDOWN) print('[*] - ' + datetime.now().strftime('%a, %d %b %Y %H:%M:%S') + '\n' +