Example #1
0
 def execute(self, **kwargs):
     status = 202
     bundle_name_pns = [self.sanitize(bundle_name_pn) for bundle_name_pn in self.args.bundle_name_pns]
     bundles = Bundle.bundles(bundle_name_pns)
     blacklist.check(bundles, self.args.blacklist_overrides)
     bundles = self.authority.revoke_certificates(
         bundles,
         self.args.bug)
     for bundle in bundles:
         bundle.expiry = Bundle.timestamp
         bundle.to_disk()
     json = self.transform(bundles)
     return json, status
Example #2
0
def reddit(jenni, input):
    """Queries Reddit."""
    query = input.group(2)
    if not query:
        return
    
    query = query.encode('utf-8')

    if blacklist.check(query, input.nick):
        return

    if not query:
        return jenni.reply('what?')

    if query not in ['opensource', 'programming', 'webdev']:
        return jenni.say('Only opensource, programming and webdev subreddits available at this time')

    try:
        r = praw.Reddit(user_agent='my_cool_application')
        submissions = r.get_subreddit(query).get_hot(limit=1)
        for topic in submissions:
            title=topic.title.encode('utf-8').strip()
            jenni.say(title + ' [' + str(topic.short_link) + ']')
    except:
        jenni.say('An unforgivable error occurred with my shitty programming')
Example #3
0
 def execute(self, **kwargs):
     status = 201
     bundle_name_pns = [
         self.sanitize(bundle_name_pn)
         for bundle_name_pn in self.args.bundle_name_pns
     ]
     bundles = Bundle.bundles(bundle_name_pns)
     blacklist.check(bundles, self.args.blacklist_overrides)
     authority = self.args.get('authority', None)
     destinations = self.args.get('destinations', None)
     if authority == None and destinations == None:
         raise MissingUpdateArgumentsError(self.args)
     if self.args.get('authority', None):
         bundles = self.renew(bundles, **kwargs)
     if self.args.get('destinations', None):
         bundles = self.deploy(bundles, **kwargs)
     json = self.transform(bundles)
     return json, status
Example #4
0
def urbandictionary(jenni, input):
    try:
        query = input.group(2)

        if blacklist.check(query, input.nick):
            return

        uri = query.replace(' ', '+')
        response = urllib.urlopen(ud + uri)
        data = json.loads(response.read())
        jenni.say(data['list'][0]['definition'])

    except Exception as e:
        jenni.say('An error occurred trying to get your definition')
        pass
Example #5
0
def ip_lookup(jenni, input):
    if not input.owner:
        return
    
    txt = input.group(2)

    if blacklist.check(txt, input.nick):
        return

    if not txt:
        return jenni.reply("No search term!")
    txt = uc.encode(txt)
    query = uc.decode(txt)
    response = "[IP/Host Lookup] "
    try:
        page = web.get(base + txt)
    except IOError, err:
        return jenni.say('Could not access given address. (Detailed error: %s)' % (err))
Example #6
0
def init(bot, update):
    '''if update.message is not None:
    if update.message.photo is not None:
      photo = update.message.photo
      #print(update)
      try:
        if photo[0].width == 90 and photo[0].file_size > 1050 and photo[0].file_size < 1100 and photo[0].height > 40 and photo[0].height < 50:
          bot.send_message(config.channel_id, ('Binance spam found in Chat %s Deleted.' % update.message.chat.title), parse_mode=ParseMode.HTML)
          bot.delete_message(update.message.chat_id, update.message.message_id)
      except IndexError:
        pass'''
    pass

    ping(bot, update)
    check_operations(bot, update)
    global log_enabled
    global hammer
    if config.debug:
        util.debug(update)

    if update.message is not None and update.message.chat.type in [
            "supergroup", "group"
    ]:

        for new in update.message.new_chat_members:
            if new.name == config.bot_username:
                check_registration(bot, update)

        db = MySQLdb.connect(config.database['server'],
                             config.database['user'],
                             config.database['password'],
                             config.database['name'])
        db.autocommit(True)
        cur = db.cursor()
        cur.execute("SELECT * FROM Groups WHERE Chat_ID = '" +
                    str(update.message.chat_id) + "'")
        row = cur.fetchone()

        check_verified_user(bot, update)
        if row[3] is not None:
            if row[3] == 1:
                if row[4] == 1:  #ConfLog
                    log_enabled = False
                if row[5] == 1:  #ConfSpamWords
                    antispam.message_text(bot, update)
                if row[7] == 1:  #ConfSpamUser
                    antispam.new_user_name(bot, update)
                if row[8] == 1:  #ConfScam
                    pass
                if row[9] == 1:  #ConfBlacklist
                    blacklist.check(bot, update)
                if row[10] == 1:  #ConfHammer
                    for new in update.message.new_chat_members:
                        bot.restrict_chat_member(
                            row[2], new.id,
                            datetime.datetime.now() +
                            datetime.timedelta(days=1))
        else:
            admin.leave(bot, update, True)

        cur.close()
        db.close()
    else:
        admin.leave(bot, update, True)
Example #7
0
        print 'main.py help   show this message and exit'
        print 'main.py update update the file used as a test case and comparator, please run this parameter'
        print '               before you run the daemon'
        print 'main.py        run the daemon'
        exit()
    else:
        print 'unknown argument(s)'

while 1 == 1:
    list1 = os.listdir(paths.rootCompilerPath + 'upload/')
    pat = re.compile('index.html')
    for i in list1:
        if i[0] == '.':
            continue
        if pat.search(i) != None:
            continue
        comp = Compiler(paths.rootCompilerPath + 'upload/' + i)
        if blacklist.check(paths.rootCompilerPath + 'upload/' + i):
            comp.malcode()
        else:
            comp.compile()
            g = comp.test()
            os.system('mkdir -p ' + paths.rootCompilerPath + 'backup/'
                      + comp.soal)
        os.system('mv -f ' + paths.rootCompilerPath + 'upload/' + i + ' '
                  + paths.rootCompilerPath + 'backup/' + comp.soal + '/'
                  )
        if comp.compiled != 1:
            continue
        os.system('rm -f ' + comp.outputPath + '*')