Example #1
0
import os
import discord
from dbconnect import db
from discord.ext import commands
from dotenv import load_dotenv

load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')

db1 = db()

bot = commands.Bot(command_prefix='sb.')

@bot.command(name='hi', help='It doesnt')
async def hello(ctx):
    response = 'Hello'
    await ctx.send(response)
    await ctx.message.add_reaction(":python3:833046001475780609")


@bot.command(name='ty', help='It doesnt')
async def danke(ctx):
    response = 'You\'re welcome'
    await ctx.send(response)

@bot.command(name='start', help="Initializes your user in the DB and gives you coins to start playing with!")
async def init_user(ctx):
    response = db1.init_user(ctx.message.author)
    await ctx.send(response)

@bot.command(name='nextup', help="Shows x number of next games (max x = 8)", aliases = ['nextmatches', 'nm', 'nextmatch'])
Example #2
0
FEEDCHECKPATTERNS = [
    re.compile('latest feed from (.*)\?', re.IGNORECASE),
    re.compile('the (.*?) feed (?:last :?)?updated', re.IGNORECASE),
]
STATUSPATTERN = re.compile('your (status|situation|20|condition)',
                           re.IGNORECASE)
GRUMBLEPATTERN = re.compile(
    '(grumble|stupid|argh|ugh|barf|bad bot|bad robot) ', re.IGNORECASE)
TITLECLEANPATTERN = re.compile(
    '^(\d\:\d\d)-(cr|cv|mi|mc|ms|misc|sw)-([\d\-]{4,}) ', re.IGNORECASE)
FAMOUSPATTERN = re.compile('re famous', re.IGNORECASE)
TRYINGPATTERN = re.compile(
    '(keep trying|keep at it|find it later|look for it later|keep looking)',
    re.IGNORECASE)

db = dbconnect.db()

case_file = open('bigcases.json')
case_data = json.load(case_file)
cases = case_data['cases']
cases_sct = case_data['supreme_court_cases']


# Do the formatting and stff on a list of message choices; return message and images
# Note that the recipient identifier should travel WITH THE @ SYMBOL ATTACHED
def postreply(l, sender, id=None, recipient=None):
    global tw
    images = []
    media_id = None
    reply = {}
    print 'ok'
Example #3
0
chrome_options.add_experimental_option('prefs',profile)



START = 'https://pacer.login.uscourts.gov/csologin/login.jsf?appurl=pcl.uscourts.gov/search'
ACCESS = 'public'

URL = re.compile('"(http.*?)"', re.IGNORECASE)
COSTS =[
	re.compile('Cost: </FONT></TH><TD ALIGN=LEFT><FONT SIZE=-1 COLOR=DARKBLUE>(.*?)<', re.IGNORECASE), 
	re.compile('Cost: </font></th><td align="LEFT"><font size="-1" color="DARKBLUE">(.*?)<', re.IGNORECASE),
	re.compile('Cost: .{50,80}>([\s\d\.]{3,7})<', re.IGNORECASE)
]	

dc = DocumentCloud(settings.dc_user, settings.dc_pass)
db = dbconnect.db(host=settings.db_host, user=settings.db_user, pwd=settings.db_pass, port=settings.db_port)

def handleLogin():
	print "# Renewing login"
	global br
	br.get(START)
	br.find_element_by_name('login:loginName').send_keys(settings.pacer_user)
	br.find_element_by_name('login:password').send_keys(settings.pacer_pass)
	br.find_element_by_name('login:clientCode').send_keys(settings.pacer_client)
	br.find_element_by_name('login:clientCode').send_keys(Keys.RETURN)
	time.sleep(3)
	
def getDocument(pid, url):
	global waittime
	global br
Example #4
0
class caseShare:

    VERBOSE = True

    DONOTTWEET = [
        'Notice of Appearance', 'Pro Hac Vice', 'Appear Pro Hac Vice',
        'Appearance',
        'LCvR 7.1 Certificate of Disclosure - Corporate Affiliations/Financial Interests'
    ]

    DONOTTWEETRE = re.compile(
        '(pro hac vice|notice of appearance|certificate of disclosure|corporate disclosure|add and terminate attorneys)',
        re.IGNORECASE)

    tw = Twython()

    db = dbconnect.db()

    dc = DocumentCloud('EMAIL', 'PASS')

    ROOM = 'CF1RKUUAV'

    bigcases = dict((item['court'] + item['case_number'], item)
                    for item in bigcases_list.cases)

    def __init__(self):
        if self.VERBOSE:
            self.bigCasesMessage()
        self.listNew()
        return

    def listNew(self):
        cases = self.db.getDict(""" SELECT * 
						FROM court.pacer_raw
						WHERE bigcase = 1
						ORDER BY pid DESC
						LIMIT 100 """)
        for case in cases:
            self.share(case)
            self.update(case)
        return

    def update(self, case):
        self.db.run(
            """ UPDATE court.pacer_raw
				SET bigcase = 2
				WHERE pid = %s """, (case['pid'], ))

    def twitter_upload(self, image_list):
        media_ids = []

        for image in image_list:
            try:
                res = requests.get(image)
                res.raise_for_status()

                uploadable = BytesIO(res.content)

                response = self.tw.upload_media(media=uploadable)
                media_ids.append(response['media_id'])
            except:
                pass
        return media_ids

    def share(self, case):
        uid = case['court'] + case['case_number']
        DP1 = re.compile('\[(.*?)\].*?<a href="(.*?)"', re.IGNORECASE)
        DP2 = re.compile('\[(.*?)\]', re.IGNORECASE)
        d = case['description']
        media_ids = []
        typ = DP2.search(d).group(1)
        if case['dcid'] is not None:
            link = 'https://www.usatoday.com/documents/' + case['dcid']
            nd = DP2.search(d).group(1) + '\n\n' + link
            doc = self.dc.documents.get(case['dcid'])
            images = doc.normal_image_url_list[:4]
            if len(images) > 0:
                media_ids = self.twitter_upload(images)

        elif DP1.search(d):
            link = DP1.search(d).group(2)
            nd = DP1.search(d).group(1) + '\n\nDoc. on PACER: ' + link
        elif DP2.search(d):
            nd = DP2.search(d).group(1) + '\n\nPACER Docket: ' + case['link']
        else:
            nd = False
        if nd:

            # Post everything to slack
            print 'Sending to Slack'
            try:
                msg = 'TRACKED CASE: New filing in *%s*: %s' % (
                    self.bigcases[uid]['name'], nd)
                #sc = SlackClient(dbinfo.sl_token_newsalertsbot)
                #sc.rtm_connect()
                #sc.rtm_send_message(self.ROOM, msg)
            except Exception, e:
                with open('/data/s/bigcases-err.log', 'a') as logfile:
                    logfile.write('SLACK ERROR: ' + str(e) + '\n')

            if not self.DONOTTWEETRE.search(typ):
                msg = 'New filing in %s: %s' % (self.bigcases[uid]['name'], nd)
                try:
                    if len(media_ids) > 0:
                        self.tw.update_status(status=msg, media_ids=media_ids)
                    else:
                        self.tw.update_status(status=msg)


#					x = 0
                except Exception, e:
                    print '##' + str(e)
                    pass
                print '-----------------------------'
                print media_ids
                print '' + msg
	string=""
	fo = open("../android/out_black_white.txt", "r+")
	In = fo.read().splitlines();
	fo.close()

	string_bw=""
	for i in In:
		if len(i)>5:
			string_bw = i
	fo = open("../android/out_original.txt", "r+")
	In = fo.read().splitlines();
	fo.close()
	string_o=""
	for i in In:
		if len(i)>5:
			string_o = i		
	#print string,len(string)

	if len(string_bw)>len(string_o):
		string =string_bw.replace(" ", "")
	else:
		string =string_o.replace(" ", "")	
	print string	
	print len(string)
	
	parameter_list = dbconnect.db(string,lat,lon)
	print parameter_list
	ans = emailtest.email(parameter_list)		
	if not ans:
		print "Failed"
Example #6
0
class caseShare:

    VERBOSE = True

    # List of  filing types that should not be tweeted (because they're routine and seldom interesting)
    DONOTTWEET = [
        'Notice of Appearance', 'Pro Hac Vice', 'Appear Pro Hac Vice',
        'Appearance',
        'LCvR 7.1 Certificate of Disclosure - Corporate Affiliations/Financial Interests'
    ]

    tw = Twython(settings.twitter_app_key, settings.twitter_app_secret,
                 settings.twitter_oauth_key, settings.twitter_oauth_secret)

    db = dbconnect.db(host=settings.db_host,
                      user=settings.db_user,
                      pwd=settings.db_pass,
                      port=settings.db_port)
    dc = DocumentCloud(settings.dc_user, settings.dc_pass)

    # Re-arrange list of big cases into a dict with a unique ID
    bigcases = dict((item['court'] + item['case_number'], item)
                    for item in bigcases_list.cases)

    def __init__(self):
        if self.VERBOSE:
            self.bigCasesMessage()
        self.listNew()
        return

    def listNew(self):
        # List new filings in selected cases that haven't been tweeted yet
        cases = self.db.getDict(""" SELECT * 
						FROM court.pacer_raw
						WHERE bigcase = 1
						ORDER BY pid DESC
						LIMIT 100 """)
        for case in cases:
            self.share(case)
            self.update(case)
        return

    def update(self, case):
        # Update a case after it's tweeted
        self.db.run(
            """ UPDATE court.pacer_raw
				SET bigcase = 2
				WHERE pid = %s """, (case['pid'], ))

    def twitter_upload(self, image_list):
        # Upload images of first four pages
        media_ids = []
        for image in image_list:
            try:
                res = requests.get(image)
                res.raise_for_status()
                uploadable = BytesIO(res.content)
                response = self.tw.upload_media(media=uploadable)
                media_ids.append(response['media_id'])
            except:
                pass
        return media_ids

    def share(self, case):
        # Post a new filing to Twitter
        uid = case['court'] + case['case_number']
        DP1 = re.compile('\[(.*?)\].*?<a href="(.*?)"', re.IGNORECASE)
        DP2 = re.compile('\[(.*?)\]', re.IGNORECASE)
        d = case['description']
        media_ids = []
        typ = DP2.search(d).group(1)
        if case['dcid'] is not None:
            # Best case: We have the document on DC, and probably attached images
            link = case['document_location']
            nd = DP2.search(d).group(1) + '\n\n' + link
            doc = self.dc.documents.get(case['dcid'])
            images = doc.normal_image_url_list[:4]
            if len(images) > 0:
                media_ids = self.twitter_upload(images)

        elif DP1.search(d):
            # If the document hasn't made it to DC, send the PACER link
            link = DP1.search(d).group(2)
            nd = DP1.search(d).group(1) + '\n\nDoc. on PACER: ' + link
        elif DP2.search(d):
            # If there is no document, send a link to the PACER docket for the case
            nd = DP2.search(d).group(1) + '\n\nPACER Docket: ' + case['link']
        else:
            nd = False
        if nd:
            if typ not in self.DONOTTWEET:
                msg = 'New filing in %s: %s' % (self.bigcases[uid]['name'], nd)
                try:
                    if len(media_ids) > 0:
                        self.tw.update_status(status=msg, media_ids=media_ids)
                    else:
                        self.tw.update_status(status=msg)
                except Exception, e:
                    print '##' + str(e)
                    pass

        return
Example #7
0
from io import BytesIO
import requests
import sys
import dbconnect
import bigcases_list
from pacer_rss_feeds import courts
from bigcases_settings import settings

multitask = settings.multitask
threads = settings.multitask_threads
TIMEOUT = settings.http_timeout
TITLEPATTERN = re.compile('^(.*?) (.*?)', re.IGNORECASE)

db = dbconnect.db(host=settings.db_host,
                  user=settings.db_user,
                  pwd=settings.db_pass,
                  port=settings.db_port,
                  database=settings.db_database)


def bigCaseList():
    l = []
    for case in bigcases_list.cases:
        l.append(case['court'] + case['case_number'])
    return l


def checkBigCase(court, case_number):
    if case_number is not None:
        if court + case_number in bigcases:
            return 1
Example #8
0
    string = ""
    fo = open("../android/out_black_white.txt", "r+")
    In = fo.read().splitlines()
    fo.close()

    string_bw = ""
    for i in In:
        if len(i) > 5:
            string_bw = i
    fo = open("../android/out_original.txt", "r+")
    In = fo.read().splitlines()
    fo.close()
    string_o = ""
    for i in In:
        if len(i) > 5:
            string_o = i
    #print string,len(string)

    if len(string_bw) > len(string_o):
        string = string_bw.replace(" ", "")
    else:
        string = string_o.replace(" ", "")
    print string
    print len(string)

    parameter_list = dbconnect.db(string, lat, lon)
    print parameter_list
    ans = emailtest.email(parameter_list)
    if not ans:
        print "Failed"