def respond(self, command):
     helper.logmessage('Simple Response Triggered')
     command = command.translate(str.maketrans('', '', '!-:.^')).lower()
     if command in self.responses:
         return self.responses[command]
     else:
         return ''
Example #2
0
 def load_cmc(self):
     dataarray = {}
     response = self.shitcoinrequests.get(config.cmctokens)
     respjson = response.json()
     for obj in respjson:
         dataarray[obj["symbol"]] = obj["id"]
     helper.logmessage('Loaded CoinMarketCap tokens')
     return dataarray
 def del_command(self, fbid, message):
     if fbid in config.adminfbids:
         command = str(helper.parsemessage(message).split(' ')[0]).lower()
         if command in self.responses:
             try:
                 del self.responses[command]
                 self.save_file()
                 return 'Successfully deleted command "{}"'.format(command)
             except Exception as e:
                 helper.logmessage(
                     'Command Deletion Error: {} | Message: {}'.format(
                         str(e), message))
                 return 'Could not delete command!'
         else:
             return 'Cannot delete what is not there!!'
     else:
         return 'NOOB U R NOT ADMIN'
Example #4
0
 def get_cmcaltcoin(self, token):
     helper.logmessage('Shitcoin Triggered')
     try:
         self.headers = {'X-CMC_PRO_API_KEY': config.cmcapikey}
         self.cmcid = str(self.cmcarray[token.upper()])
         response = self.shitcoinrequests.get(config.cmcapi.format(
             self.cmcid),
                                              headers=self.headers)
         cmcres = response.json()
         respstring = 'Current {} price: {} USD ({}% change)'.format(
             cmcres["data"][self.cmcid]["name"].capitalize(),
             helper.float_to_str(
                 cmcres["data"][self.cmcid]["quote"]["USD"]["price"],
                 10), cmcres["data"][self.cmcid]["quote"]["USD"]
             ["percent_change_24h"])
     except:
         respstring = ('Nothing found for ' + token)
     return respstring
    def add_command(self, message):
        try:
            messagesplit = helper.parsemessage(message).split(' ')
            command = str(messagesplit[0]).lower()

            if command in self.responses:
                return 'Command already exists! Delete the command first using !delcmd {}'.format(
                    command)

            response = str(" ".join(messagesplit[1:]))
            self.responses[command] = response
            self.save_file()
            return '"{}" command added to return "{}"'.format(
                command, response)
        except Exception as e:
            helper.logmessage(
                'Command Addition Error: {} | Message: {}'.format(
                    str(e), message))
            return 'Could not add command!'
    def get_time(self, message):
        try:
            timezone = int(helper.parsemessage(message))
        except:
            timezone = 999
        try:

            if -13 <= timezone <= 14:
                utc_datetime = datetime.datetime.utcnow()
                result_utc_datetime = utc_datetime + datetime.timedelta(
                    hours=int(timezone))
                respstring = 'Time for GMT {}: {}'.format(
                    timezone,
                    result_utc_datetime.strftime("%a %d %B - %I:%M%p"))
            else:
                respstring = 'Error: Choose a timezone between UTC-13 and UTC+14'
        except Exception as e:
            helper.logmessage(
                'Exception while getting time. Exception: {}'.format(str(e)))
            respstring = 'FUARK error'

        return respstring
    def __init__(self,
                 email,
                 password,
                 user_agent=None,
                 logging_level=logging.ERROR):
        self.iphandler = requests.Session()
        response = self.iphandler.get("http://ipv4.icanhazip.com").text
        helper.logmessage('Current IP: ' + response)
        try:
            self.session_cookies = load(open("session_cookie.json", 'rb'))
            helper.logmessage("There is a cookie file!")
            fbchat.Client.__init__(self,
                                   email,
                                   password,
                                   user_agent,
                                   max_tries=5,
                                   session_cookies=self.session_cookies)
        except:
            # Session Cookie doesn't exist
            helper.logmessage("There is no cookie file!")
            fbchat.Client.__init__(self, email, password, user_agent)

        try:
            self.session_cookies = self.getSession()
            helper.logmessage(self.session_cookies)
            dump(self.session_cookies, open("session_cookie.json", 'wb'))
        except:
            # Session Cookie doesn't exist
            pass

        self.stocks = Stocks.Stocks()
        self.shitcoins = Shitcoins.Shitcoin()
        self.simplereply = Reply.SimnpleReply()
        self.misc = Misc.Misc()

        helper.logmessage('Successfully Loaded')
 def __init__(self):
     self.load_file()
     helper.logmessage('Loaded SimpleReply Plugin')
    def onMessage(self, mid, author_id, message, message_object, thread_id,
                  thread_type, **kwargs):

        #self.markAsDelivered(thread_id, message_object.id)
        self.markAsRead(thread_id)
        if str(author_id) != str(self.uid):
            chatline = str(message_object.text).lower()
            respstring = ''

            if chatline.startswith('!stock'):
                helper.logmessage('Stock request triggered')
                respstring = self.stocks.check_stock(chatline)

            elif chatline.startswith("!decide"):
                helper.logmessage('Decision Triggered')
                respstring = self.misc.decide(chatline)

            elif chatline.startswith('!math '):
                helper.logmessage('Calculation Triggered')
                respstring = self.misc.calculate(chatline)

            elif chatline.startswith('!captcha'):
                helper.logmessage('2Captcha Called')
                respstring = self.misc.get_captchacredit()

            elif "/gyazo.com/" in chatline:
                helper.logmessage('Crappy Gyazo URL')
                respstring = self.helper.anti_gyazo(chatline)

            elif chatline.startswith('!dtime ') and len(
                    chatline.split(' ')) > 1:
                helper.logmessage('Timezone Triggered')
                respstring = self.misc.get_time(chatline)

            elif chatline.startswith('!addcmd') and len(
                    chatline.split(' ')) > 1:
                helper.logmessage('Adding Command')
                respstring = self.simplereply.add_command(
                    str(message_object.text))

            elif chatline.startswith('!delcmd') and len(
                    chatline.split(' ')) > 1:
                helper.logmessage('Deleting Command')
                respstring = self.simplereply.del_command(
                    message_object.author, chatline)

            elif chatline.startswith('!commands'):
                helper.logmessage('Command List Triggered')
                respstring = 'Commands: !addcmd <command> <response>, !captcha, !decide <1, 2, 3, ...>, !delcmd <command>, !dtime <timezone>, !math <equation>, !stock <stockcode> | '
                respstring += self.simplereply.list_commands()

            elif chatline.startswith('!'):
                messagecontent = chatline[1:]
                msg = messagecontent.split(' ')[0].upper()

                if len(msg) > 0:
                    respstring = self.simplereply.respond(msg)
                    if respstring == '':
                        respstring = self.shitcoins.get_cmcaltcoin(msg[:6])

            if respstring is not '':
                self.sendMessage(respstring,
                                 thread_id=thread_id,
                                 thread_type=thread_type)
Example #10
0
 def __init__(self):
     self.shitcoinrequests = requests.Session()
     self.cmcarray = self.load_cmc()
     helper.logmessage('Loaded Shitcoin plugin')
 def decide(self, message):
     decisions = helper.parsemessage(message).split(',')
     helper.logmessage(decisions)
     kinda_random = random.SystemRandom()
     return 'Decision: {}'.format(kinda_random.choice(decisions).strip())
 def __init__(self):
     self.miscrequests = requests.Session()
     helper.logmessage('Loaded Misc plugin')