Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from utils.media_sender import UrlPrintSender
- from yowsup.layers.protocol_messages.protocolentities.message_text import TextMessageProtocolEntity
- import random
- from somtoday import *
- import string
- import os
- import sys
- import datetime
- #default login strings
- username = "154355"
- password = "??????"
- school = "hethooghuis"
- nr = "19XH"
- class SuperKacper():
- def __init__(self, interface_layer):
- self.interface_layer = interface_layer
- self.url_print_sender = UrlPrintSender(self.interface_layer)
- self.routes = [
- ("^.cijfers", self.cijfers),
- ("^.hw", self.hw),
- ("^.nexthw", self.hwnext),
- ("^.kacper", self.about),
- ("^.caitlin", self.cait),
- ]
- def hwnext(self, message=None, match=None, to=None):
- somhw=Somtoday(username,password,school,nr)
- todayis = datetime.datetime.today().weekday()
- hw = " "
- hww = " "
- if todayis == 4:
- hw = "HW voor Dinsdag\n"
- for what in somhw.getschedule(4):
- hw = hw + what["titel"] + "\n"
- hw = hw + str(what["huiswerk"]) + "\n_________\n"
- elif todayis == 5:
- hw = "HW voor Dinsdag\n"
- for what in somhw.getschedule(3):
- hw = hw + what["titel"] + "\n"
- hw = hw + str(what["huiswerk"]) + "\n_________\n"
- for what in somhw.getschedule(2):
- hw = hw + what["titel"] + "\n"
- hw = hw + str(what["huiswerk"]) + "\n_________\n"
- hw_fix = str(hw)
- hw_fix1 = hw_fix.replace("<br>", "")
- hw_fix2 = hw_fix1.replace("<b>", "")
- hw_fix3 = hw_fix2.replace("</b>", "")
- hw_fix4 = hw_fix3.replace("</p>", "")
- hw_fix5 = hw_fix4.replace("<p>", "")
- hw_fix6 = hw_fix5.replace("<i>", "")
- hw_fix7 = hw_fix6.replace("</i>", "")
- hw_fix8 = hw_fix7.replace("<br/>", "")
- hw_fix9 = hw_fix8.replace(" ", "")
- if str(hw_fix9) == " ":
- return TextMessageProtocolEntity("Geen Huiswerk", to=message.getFrom())
- else:
- return TextMessageProtocolEntity(str(hw_fix9), to=message.getFrom())
- def cijfers(self, message=None, match=None, to=None):
- som=Somtoday(username,password,school,nr)
- gradesstring = " "
- oldf=open("grades.txt")
- oldlinesr=oldf.readlines()
- old = oldlinesr[0]
- oldf.close()
- targetnew = open("grades.txt", 'w+')
- for grades in som.getgrades():
- gradesstring = gradesstring + str(grades["vak"]) + "\n"
- targetnew.write(gradesstring)
- targetnew.close()
- newf=open("grades.txt")
- newlinesr=newf.readlines()
- new = newlinesr[0]
- newf.close()
- if old == new:
- return TextMessageProtocolEntity("Geen nieuwe cijfers", to=message.getFrom())
- else:
- return TextMessageProtocolEntity("Nieuwe cijfer voor" + new, to=message.getFrom())
- def hw(self, message=None, match=None, to=None):
- somhw=Somtoday(username,password,school,nr)
- todayis = datetime.datetime.today().weekday()
- hw = " "
- hww = " "
- if todayis == 4:
- hw = "HW voor Maandag\n"
- for what in somhw.getschedule(3):
- hw = hw + what["titel"] + "\n"
- hw = hw + str(what["huiswerk"]) + "\n_________\n"
- elif todayis == 5:
- hw = "HW voor Maandag\n"
- for what in somhw.getschedule(2):
- hw = hw + what["titel"] + "\n"
- hw = hw + str(what["huiswerk"]) + "\n_________\n"
- for what in somhw.getschedule(1):
- hw = hw + what["titel"] + "\n"
- hw = hw + str(what["huiswerk"]) + "\n_________\n"
- hw_fix = str(hw)
- hw_fix1 = hw_fix.replace("<br>", "")
- hw_fix2 = hw_fix1.replace("<b>", "")
- hw_fix3 = hw_fix2.replace("</b>", "")
- hw_fix4 = hw_fix3.replace("</p>", "")
- hw_fix5 = hw_fix4.replace("<p>", "")
- hw_fix6 = hw_fix5.replace("<i>", "")
- hw_fix7 = hw_fix6.replace("</i>", "")
- hw_fix8 = hw_fix7.replace("<br/>", "")
- hw_fix9 = hw_fix8.replace(" ", "")
- if str(hw_fix9) == " ":
- return TextMessageProtocolEntity("Geen Huiswerk", to=message.getFrom())
- else:
- return TextMessageProtocolEntity(str(hw_fix9), to=message.getFrom())
- def about(self, message=None, match=None, to=None):
- return TextMessageProtocolEntity(HELP_TEXT, to=message.getFrom())
- def cait(self, message=None, match=None, to=None):
- return TextMessageProtocolEntity("Caitlin :D", to=message.getFrom())
- HELP_TEXT = """ [HELP]
- - Bot gemaakt door Kacper S.
- Gemaakt met behulp van:
- Python 2.7 []
- Raspberry Pi B+ []
- SomToday API [git]
- yowsup [git]
- WA-bot-API [git]
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement