Beispiel #1
0
 def __init__(self):
     self.client = zulip.Client(site="https://fazeup.zulipchat.com/api/")
     self.subscribe_all()
     self.hacknews = Hackernews()
     self.trans = Translate()
     self.movie = Movie()
     self.lyrics = Lyrics()
     self.holiday = Holiday()
     self.currency = Currency()
     self.cricket = Cricket()
     # self.chatbot.train("chatterbot.corpus.english")
     self.crypto = Crypto()
     self.trans = Translate()
     self.g = Giphy()
     self.w = WikiPedia()
     # self.tw = Twimega()
     # self.motivate = Motivate()
     self.shortenedurl = Urlshortener()
     self.geo = Geocode()
     self.weather = Weather()
     self.dict_ = Dictionary()
     self.joke = Joke()
     self.pnr = Pnr()
     self.mustread = Mustread()
     self.ss = Ss()
     self.cricket = Cricket()
     self.poll = Poll()
     print("done init")
     self.subkeys = [
         "crypto", "translate", "define", "joke", "weather", "giphy", "pnr",
         "mustread", "poll", "hackernews", "hn", "HN", "motivate",
         "twitter", "screenshot", "memo", "cricnews", "help", "shorturl",
         "movie", "currency", "holiday", "lyrics"
     ]
Beispiel #2
0
	def __init__(self):
		self.client = zulip.Client(site="https://technh.zulipchat.com/api/", api_key="vkEQgQYDPUgAGmXaTXdMPsMwlkkgMfM5", email="*****@*****.**")
		self.subscribe_all()
		self.hacknews = Hackernews()
		self.trans = Translate()
		self.movie= Movie()
		self.lyrics = Lyrics()
		self.holiday = Holiday()
		self.currency = Currency()
		self.cricket = Cricket()
		self.github = GitHub()
		self.chatbot = ChatBot(name="technehru")

		print("done init")
		self.subkeys = ["use", "help", "translate", "hackernews", "hn", "hotel", "HN", "cricnews", "cricketnews", "movie", "currency", "holiday", "lyrics", "github"]
Beispiel #3
0
    def __init__(self):
        self.client = zulip.Client(site="https://myra.zulipchat.com/api/")
        self.subscribe_all()
        self.hacknews = Hackernews()
        self.trans = Translate()
        self.movie = Movie()
        self.lyrics = Lyrics()
        self.holiday = Holiday()
        self.currency = Currency()
        self.cricket = Cricket()

        print("done init")
        self.subkeys = [
            "translate", "hackernews", "hn", "hotel", "HN", "askme",
            "cricnews", "movie", "currency", "holiday", "lyrics"
        ]
Beispiel #4
0
import datetime
import re

from bs4 import BeautifulSoup

from auth3 import Auth
from holiday import Holiday
from timetable import Timetable

timetable = Timetable()
holiday = Holiday()


def course_handler(cookies, xnxqid, start_date, output_dir='.'):
    auth = Auth(cookies)

    if not auth.ok:
        raise Exception('登录失败,请检查用户名密码')

    url = 'https://jwxt.sztu.edu.cn/jsxsd/xskb/xskb_list.do?xnxq01id=' + xnxqid
    start_date = start_date.split('-')
    r = auth.get(url)

    soup = BeautifulSoup(r.text, features='html.parser')

    tab = soup.findAll('table')[0]

    i = 0

    schedules = []
Beispiel #5
0
#!/usr/bin/env python3

import datetime
from dateutil.parser import parse

from holiday import Holiday

print("")
#Look up if there are any holidays today
today = datetime.date.today()
h = Holiday(today.strftime('%B'), today.day)
print("")
print("")

while True:
    lookup_date = input('Date: ')
    print("")
    if 'q' in str(lookup_date.lower()):
        exit()
    else:
        newday = parse(lookup_date)
        h = Holiday(newday.strftime('%B'), newday.day)
    print("")
    print("")
Beispiel #6
0
class ZulipBot(object):
    def __init__(self):
        self.client = zulip.Client(site="https://fazeup.zulipchat.com/api/")
        self.subscribe_all()
        self.hacknews = Hackernews()
        self.trans = Translate()
        self.movie = Movie()
        self.lyrics = Lyrics()
        self.holiday = Holiday()
        self.currency = Currency()
        self.cricket = Cricket()
        # self.chatbot.train("chatterbot.corpus.english")
        self.crypto = Crypto()
        self.trans = Translate()
        self.g = Giphy()
        self.w = WikiPedia()
        # self.tw = Twimega()
        # self.motivate = Motivate()
        self.shortenedurl = Urlshortener()
        self.geo = Geocode()
        self.weather = Weather()
        self.dict_ = Dictionary()
        self.joke = Joke()
        self.pnr = Pnr()
        self.mustread = Mustread()
        self.ss = Ss()
        self.cricket = Cricket()
        self.poll = Poll()
        print("done init")
        self.subkeys = [
            "crypto", "translate", "define", "joke", "weather", "giphy", "pnr",
            "mustread", "poll", "hackernews", "hn", "HN", "motivate",
            "twitter", "screenshot", "memo", "cricnews", "help", "shorturl",
            "movie", "currency", "holiday", "lyrics"
        ]

    def subscribe_all(self):
        json = self.client.get_streams()["streams"]
        streams = [{"name": stream["name"]} for stream in json]
        self.client.add_subscriptions(streams)

    def process(self, msg):
        content = msg["content"].split()
        sender_email = msg["sender_email"]
        ttype = msg["type"]
        stream_name = msg['display_recipient']
        stream_topic = msg['subject']

        print(content)

        if sender_email == BOT_MAIL:
            return

        print("Sucessfully heard.")

        if content[0].lower() == "magnus" or content[0] == "@**magnus**":
            if content[1].lower() == "translate":
                ip = content[2:]
                ip = " ".join(ip)
                message = self.trans.translate(ip)
                self.client.send_message({
                    "type": "stream",
                    "subject": msg["subject"],
                    "to": msg["display_recipient"],
                    "content": message
                })
            if content[1].lower() == "movie":
                ip = content[2:]
                ip = " +".join(ip)
                message = self.movie.about(ip)
                self.client.send_message({
                    "type": "stream",
                    "subject": msg["subject"],
                    "to": msg["display_recipient"],
                    "content": message
                })

            if content[1].lower() == "lyrics":
                author = content[2]
                title = content[3:]
                title = " ".join(title)
                message = self.lyrics.about(author, title)
                self.client.send_message({
                    "type": "stream",
                    "subject": msg["subject"],
                    "to": msg["display_recipient"],
                    "content": message
                })
            if content[1].lower() == 'holiday':
                quote_data = self.holiday.holiday()
                self.client.send_message({
                    "type": "stream",
                    "to": stream_name,
                    "subject": stream_topic,
                    "content": quote_data
                })

            if content[1].lower() == 'currency':
                x = content[2]
                y = content[3]

                quote_data = self.currency.currency(x, y)
                self.client.send_message({
                    "type": "stream",
                    "to": stream_name,
                    "subject": stream_topic,
                    "content": quote_data
                })

            if content[1].lower() == "cricnews":
                news = self.cricket.news()
                self.client.send_message({
                    "type": "stream",
                    "subject": msg["subject"],
                    "to": msg["display_recipient"],
                    "content": news
                })

            if content[1].lower() == 'hackernews' or content[1].lower(
            ) == 'hn' or content[1].lower() == 'HN':
                news = self.hacknews.get_hackernews()
                self.client.send_message({
                    "type": "stream",
                    "to": stream_name,
                    "subject": stream_topic,
                    "content": news
                })

            if content[1].lower() == "crypto":
                if len(content) > 3 and content[3].lower() == "in":
                    message = self.crypto.get_price(content[2], content[4])
                else:
                    message = self.crypto.get_price(content[2])
                self.client.send_message({
                    "type": "stream",
                    "subject": msg["subject"],
                    "to": msg["display_recipient"],
                    "content": message
                })

            if content[1].lower() == "joke":
                text = self.joke.tellJoke()
                self.client.send_message({
                    "type": "stream",
                    "subject": msg["subject"],
                    "to": msg["display_recipient"],
                    "content": text
                })

            # if content[1].lower() == 'motivate':
            # 	quote_data = self.motivate.get_quote()
            # 	self.client.send_message({
            # 		"type": "stream",
            # 		"to": stream_name,
            # 		"subject": stream_topic,
            # 		"content": quote_data
            # 		})
            if content[1].lower() == "mustread":
                email = self.mustread.get_email(self.client.get_members(),
                                                msg["content"])
                senderusername = self.mustread.get_username(
                    self.client.get_members(), msg["sender_email"])
                print(email)
                self.client.send_message({
                    "type":
                    "private",
                    "to":
                    email,
                    "content":
                    "**" + senderusername +
                    "** mentioned you in must read ! \nThe message says : " +
                    " ".join(content[2:])
                })

            if content[1].lower() == "pnr":
                message = self.pnr.get_pnr(content[2])
                self.client.send_message({
                    "type": "stream",
                    "subject": msg["subject"],
                    "to": msg["display_recipient"],
                    "content": message
                })
            if content[1].lower() == "screenshot":
                result = self.ss.get_ss(content[2])
                print(result)
                self.client.send_message({
                    "type":
                    "stream",
                    "subject":
                    msg["subject"],
                    "to":
                    msg["display_recipient"],
                    "content":
                    "Screenshot taken :wink:\n[Screenshot Link](" + result +
                    ")"
                })

            if content[1].lower() == "poll":
                if content[2].lower() == "create":
                    print(",".join(content[4:]))
                    idno = self.poll.create_poll(content[3], content[4:])
                    self.client.send_message({
                        "type":
                        "stream",
                        "subject":
                        msg["subject"],
                        "to":
                        msg["display_recipient"],
                        "content":
                        "Poll Successfully Created and id is : **" +
                        str(idno) + "**"
                    })
                elif content[2].lower() == "show":
                    if content[3].lower() == "all":
                        polldetails = self.poll.show_allpoll()
                        self.client.send_message({
                            "type": "stream",
                            "subject": msg["subject"],
                            "to": msg["display_recipient"],
                            "content": polldetails
                        })
                    else:
                        polldetails = self.poll.show_poll(content[3])
                        self.client.send_message({
                            "type":
                            "stream",
                            "subject":
                            msg["subject"],
                            "to":
                            msg["display_recipient"],
                            "content":
                            "Poll ID: **" + polldetails["id"] +
                            "**\n Question : **" + polldetails["pollname"] +
                            "**\nOption : **" + polldetails["options"] +
                            "**\n Votes : **" + polldetails["votes"] + "**"
                        })
                elif content[2].lower() == "vote":
                    vote = self.poll.vote_poll(content[3], content[4])
                    self.client.send_message({
                        "type":
                        "stream",
                        "subject":
                        msg["subject"],
                        "to":
                        msg["display_recipient"],
                        "content":
                        "Your Vote Has Been Recorded!"
                    })
                elif content[2].lower() == "delete":
                    if content[3].lower() == "all":
                        deleted = self.poll.delete_allpoll()
                        self.client.send_message({
                            "type":
                            "stream",
                            "subject":
                            msg["subject"],
                            "to":
                            msg["display_recipient"],
                            "content":
                            "all polls has been removed from database"
                        })
                    else:
                        deleted = self.poll.delete_poll(content[3])
                        self.client.send_message({
                            "type":
                            "stream",
                            "subject":
                            msg["subject"],
                            "to":
                            msg["display_recipient"],
                            "content":
                            "The given poll has been removed from database"
                        })

            if content[1].lower() == "shorturl":
                short_url = self.shortenedurl.get_shorturl(content)
                self.client.send_message({
                    "type": "stream",
                    "to": stream_name,
                    "subject": stream_topic,
                    "content": short_url
                })

            if content[1] not in self.subkeys:
                ip = content[1:]
                ip = " ".join(ip)
                message = self.Chatbot.get_response(ip).text
                self.client.send_message({
                    "type": "stream",
                    "subject": msg["subject"],
                    "to": msg["display_recipient"],
                    "content": message
                })

        elif "magnus" in content and content[0] != "magnus":
            self.client.send_message({
                "type": "stream",
                "subject": msg["subject"],
                "to": msg["display_recipient"],
                "content": "Hey there! :blush:"
            })
        else:
            return
Beispiel #7
0
class ZulipBot(object):
    def __init__(self):
        self.client = zulip.Client(site="https://myra.zulipchat.com/api/")
        self.subscribe_all()
        self.hacknews = Hackernews()
        self.trans = Translate()
        self.movie = Movie()
        self.lyrics = Lyrics()
        self.holiday = Holiday()
        self.currency = Currency()
        self.cricket = Cricket()

        print("done init")
        self.subkeys = [
            "translate", "hackernews", "hn", "hotel", "HN", "askme",
            "cricnews", "movie", "currency", "holiday", "lyrics"
        ]

    def subscribe_all(self):
        json = self.client.get_streams()["streams"]
        streams = [{"name": stream["name"]} for stream in json]
        self.client.add_subscriptions(streams)

    def process(self, msg):
        content = msg["content"].split()
        sender_email = msg["sender_email"]
        ttype = msg["type"]
        stream_name = msg['display_recipient']
        stream_topic = msg['subject']

        print(content)

        if sender_email == BOT_MAIL:
            return

        print("Sucessfully heard.")

        if content[0].lower() == "myra" or content[0] == "@**myra**":
            if content[1].lower() == "translate":
                ip = content[2:]
                ip = " ".join(ip)
                message = self.trans.translate(ip)
                self.client.send_message({
                    "type": "stream",
                    "subject": msg["subject"],
                    "to": msg["display_recipient"],
                    "content": message
                })
            if content[1].lower() == "movie":
                ip = content[2:]
                ip = " +".join(ip)
                message = self.movie.about(ip)
                self.client.send_message({
                    "type": "stream",
                    "subject": msg["subject"],
                    "to": msg["display_recipient"],
                    "content": message
                })

            if content[1].lower() == "lyrics":
                author = content[2]
                title = content[3:]
                title = " ".join(title)
                message = self.lyrics.about(author, title)
                self.client.send_message({
                    "type": "stream",
                    "subject": msg["subject"],
                    "to": msg["display_recipient"],
                    "content": message
                })
            if content[1].lower() == 'holiday':
                quote_data = self.holiday.holiday()
                self.client.send_message({
                    "type": "stream",
                    "to": stream_name,
                    "subject": stream_topic,
                    "content": quote_data
                })

            if content[1].lower() == 'currency':
                x = content[2]
                y = content[3]

                quote_data = self.currency.currency(x, y)
                self.client.send_message({
                    "type": "stream",
                    "to": stream_name,
                    "subject": stream_topic,
                    "content": quote_data
                })

            if content[1].lower() == "cricnews":
                news = self.cricket.news()
                self.client.send_message({
                    "type": "stream",
                    "subject": msg["subject"],
                    "to": msg["display_recipient"],
                    "content": news
                })

            if content[1].lower() == 'hackernews' or content[1].lower(
            ) == 'hn' or content[1].lower() == 'HN':
                news = self.hacknews.get_hackernews()
                self.client.send_message({
                    "type": "stream",
                    "to": stream_name,
                    "subject": stream_topic,
                    "content": news
                })

            if content[1] not in self.subkeys:
                ip = content[1:]
                ip = " ".join(ip)
                message = self.chatbot.get_response(ip).text
                self.client.send_message({
                    "type": "stream",
                    "subject": msg["subject"],
                    "to": msg["display_recipient"],
                    "content": message
                })

        elif "myra" in content and content[0] != "myra":
            self.client.send_message({
                "type": "stream",
                "subject": msg["subject"],
                "to": msg["display_recipient"],
                "content": "Hey there! :blush:"
            })
        else:
            return
Beispiel #8
0
        'method': 'logout',
        'sessionkey': None,
    }
    cookies = session.cookies.get_dict()
    query_params['sessionkey'] = cookies.get('JSESSIONID')
    resp = session.get(BASE_URL, params=query_params, headers=headers)
    if resp.json().get('error'):
        return None
    return 'ok'
    
def start_cheat():
    session = requests.Session()
    login_result = login(session)
    # addr, latitude, longitude = get_location(session)
    addr, latitude, longitude = '%E4%B8%8A%E6%B5%B7%E5%B8%82%E5%BE%90%E6%B1%87%E5%8C%BA%E8%99%B9%E6%A1%A5%E8%B7%AF%E9%9D%A0%E8%BF%91%E6%B8%AF%E6%B1%87%E6%81%92%E9%9A%86%E5%B9%B%E5%9C%BA', 31.19409478081597, 121.4371006944444
    # checkin_result = checkin(session, addr, latitude, longitude)
    checkout_result = checkout(session, addr, latitude, longitude)
    logout_result = logout(session)
    print('login_result', login_result)
    print(addr, latitude, longitude)
    print('checkout_result', checkout_result)
    print('logout_result', logout_result)  

if __name__ == '__main__':
    h = Holiday()
    if not h.isHoliday():
        minute = [i for i in range(1, 35, 5)] + [j for j in range(3, 40, 2)]
        sleep_seconds = random.choice(minute) * 60
        print(sleep_seconds)
        time.sleep(sleep_seconds)
        start_cheat()
Beispiel #9
0
class ZulipBot(object):
	def __init__(self):
		self.client = zulip.Client(site="https://technh.zulipchat.com/api/", api_key="vkEQgQYDPUgAGmXaTXdMPsMwlkkgMfM5", email="*****@*****.**")
		self.subscribe_all()
		self.hacknews = Hackernews()
		self.trans = Translate()
		self.movie= Movie()
		self.lyrics = Lyrics()
		self.holiday = Holiday()
		self.currency = Currency()
		self.cricket = Cricket()
		self.github = GitHub()
		self.chatbot = ChatBot(name="technehru")

		print("done init")
		self.subkeys = ["use", "help", "translate", "hackernews", "hn", "hotel", "HN", "cricnews", "cricketnews", "movie", "currency", "holiday", "lyrics", "github"]

	def subscribe_all(self):
		json = self.client.get_streams()["streams"]
		streams = [{"name": stream["name"]} for stream in json]
		self.client.add_subscriptions(streams)

	def process(self, msg):
		content = msg["content"].split()
		sender_email = msg["sender_email"]
		ttype = msg["type"]
		stream_name = msg['display_recipient']
		stream_topic = msg['subject']

		print(content)

		if sender_email == BOT_MAIL:
			return 

		print("Sucessfully heard.")

		if content[0].lower() == "technehru" or content[0] == "@**Technehru**":
			if content[1].lower() == "help" or content[1].lower() == "use":
				message = open("help.txt", "r")
				self.client.send_message({
					"type": "stream",
					"to": stream_name,
					"subject": stream_topic,
					"content": message.read()
					})

			if content[1].lower() == "translate":
				ip = content[2:]
				ip = " ".join(ip)
				message = self.trans.translate(ip)
				self.client.send_message({
					"type": "stream",
					"subject": msg["subject"],
					"to": msg["display_recipient"],
					"content": message
					})
			if content[1].lower() == "movie":
				ip = content[2:]
				ip = " +".join(ip)
				message = self.movie.about(ip)
				self.client.send_message({
					"type": "stream",
					"subject": msg["subject"],
					"to": msg["display_recipient"],
					"content": message
					})

			if content[1].lower() == "lyrics":
				author = content[2]
				title = content[3:]
				title = " ".join(title)
				message = self.lyrics.about(author, title)
				self.client.send_message({
					"type": "stream",
					"subject": msg["subject"],
					"to": msg["display_recipient"],
					"content": message
					})

			if content[1].lower() == 'holiday':
				quote_data = self.holiday.holiday()
				self.client.send_message({
					"type": "stream",
					"to": stream_name,
					"subject": stream_topic,
					"content": quote_data
					})

			if content[1].lower() == 'currency':
				x = content[2]
				y = content[3]

				quote_data = self.currency.currency(x,y)
				self.client.send_message({
					"type": "stream",
					"to": stream_name,
					"subject": stream_topic,
					"content": quote_data
					})

			if content[1].lower() == "cricnews" or content[1].lower() == "cricketnews":
				news = self.cricket.news()
				self.client.send_message({
					"type": "stream",
					"subject": msg["subject"],
					"to": msg["display_recipient"],
					"content": news  
					})

			if content[1].lower() == 'hackernews' or content[1].lower() == 'hn':
				news = self.hacknews.get_hackernews()
				self.client.send_message({
					"type": "stream",
					"to": stream_name,
					"subject": stream_topic,
					"content": news
					})

			if content[1].lower() == 'github':
				if content[2].lower() == 'reopen' and content[3].lower() == 'issue':
					repo = content[4]
					num = int(content[5])
					result = self.github.reopen_issue(repo, num)
					self.client.send_message({
						"type": "stream",
						"to": stream_name,
						"subject": stream_topic,
						"content": result  
						})

				if content[2].lower() == 'comment' and content[3].lower() == 'issue':
					repo = content[4]
					num = int(content[5])
					comment = content[6:]
					comment = " ".join(comment)
					result = self.github.comment_issue(repo, num, comment)
					self.client.send_message({
						"type": "stream",
						"to": stream_name,
						"subject": stream_topic,
						"content": result  
						})

				if content[2].lower() == 'close' and content[3].lower() == 'issue':
					repo = content[4]
					num = int(content[5])
					result = self.github.close_issue(repo, num)
					self.client.send_message({
						"type": "stream",
						"to": stream_name,
						"subject": stream_topic,
						"content": result  
						})

				if content[2].lower() == 'assign' and content[3].lower() == 'issue':
					repo = content[4]
					num = int(content[5])
					assignee = content[6]
					result = self.github.assign_issue(repo, num, assignee)
					self.client.send_message({
						"type": "stream",
						"to": stream_name,
						"subject": stream_topic,
						"content": result  
						})


			if content[1] not in self.subkeys:
				ip = content[1:]
				ip = " ".join(ip)
				message = self.chatbot.get_response(ip).text
				self.client.send_message({
					"type": "stream",
					"subject": msg["subject"],
					"to": msg["display_recipient"],
					"content": message
					})

		
		elif "technehru" in content and content[0].lower() != "technehru":
			self.client.send_message({
				"type": "stream",
				"subject": msg["subject"],
				"to": msg["display_recipient"],
				"content": "Hey there! :blush:"
				})
		else:
			return
Beispiel #10
0
import re
import datetime
from bs4 import BeautifulSoup
from timetable import Timetable
from holiday import Holiday
from config import config
from auth import Auth
auth = Auth()
timetable = Timetable()
holiday = Holiday()

xnxqid = config.get('core', 'xnxqid')
url = 'https://isea.sztu.edu.cn/jsxsd/xskb/xskb_list.do?xnxq01id=' + xnxqid
r = auth.session.get(url, timeout=2)

soup = BeautifulSoup(r.text, features='html.parser')

tab = soup.findAll('table')[1]

i = 0

schedules = []

for tr in tab.findAll('tr'):
    if '--------' in tr.getText():
        day = 0
        for td in tr.findAll('td'):
            # 过滤掉备注
            if '--------' in td.getText():
                # print(td)
                # 处理多节课占用同一时间段