def __init__(self,email,password, kwargs):
        """"abstract class being parent of every user implemented behaviour;
         it handles logging in and tasks on behaviour loader side"""
        self.kwargs=kwargs
        Client.__init__(self, email=email, password=password)

        self.Run()
Example #2
0
    def __init__(self, email, password):
        Client.__init__(self, email, password)  # call the Client class default init
        self.command_list = {
            'help': self.command_help,
            'wiki': self.command_wiki,
            'dance': self.command_dance,
            'weeb': self.command_weeb,
            'change': self.command_change,
            'zadyma': self.command_zadymiarnia,
            'calc': self.command_calc
        }  # 'coto':self.command_coto,'dance':self.command_dance,'weeb':self.command_weeb,'zmiany':self.command_zmiany}

        self.help_text = {
            'wiki': "Wiki function searches wikipedia for the definition of a given keyword",

            'dance': "Dance command sends a gif of dancing rockalone2k, you can specify the type of the dance by using 'def' or 'alter' argument after the command",

            'weeb': "Weeb command displays a random gif with an anime girl, you can specify level of your 'weebness' by using 'nsfw' keyword after !weeb ",

            'zmiany': "Zmiany command changes the overall look of chat",

            'change': "Change command changes the overall look of chat ",

            'zadyma': "A list of zadymiarnia commands: \n1. Head\n2. Szef\n3. Rafon\n4. B*****b",

            'calc': "A simple calculator, just enter an operation of your desire :)"
        }
Example #3
0
	def __init__(self, email, password, reply_dict, **kwargs):
		Client.__init__(self, email, password)
		self.user_history = defaultdict(list)
		# self.user_history {thread_id: [[(bot_id, in_group_id, ab_test_id, msg, user_response_time), () ....], [], [], ...]}
		self.reply_dict = reply_dict
		self.user_name_dict = {}
		self.user_bot_dict = {}
		self.user_problem_dict = {}
		self.params = Params()
		self.config = Config()

		
		self.voice_choice = False

		additional_bot_control = kwargs.get('add_bot_ctl',{})
		if 'sleeping_time' in additional_bot_control:
			self.params.set_sleeping_time(additional_bot_control.get('sleeping_time'))

		if 'bot_choice' in additional_bot_control:
			self.params.set_bot_choice(additional_bot_control.get('bot_choice'))

		if 'mode' in additional_bot_control:
			self.params.set_mode(additional_bot_control.get('mode', 'text'))
			if self.params.MODE == Modes.VOICE:
				self.voice_choice == True

		if self.params.MODE == Modes.TEXT:
			self.db = MongoClient().textbot
		else:
			self.db = MongoClient().voicebot


		self.start_now = {}
		self.user_time = {}
Example #4
0
 def __init__(self, email, password, session_cookies):
     Client.__init__(self, email, password, session_cookies=session_cookies)
     self.cur_version = 'v0.3-Alpha'
     self.cur_dm = '0'   # For the DnD features, the current DM(Dungeon Master)
     self.current_rule = 'coc'   # The current rule for stat rolls (dnd/coc)
     try:
         # An alias is a way for the bot to refer to users while executing certain commands
         # An alias can be set by the user with the command !setalias <alias>
         # The format of the alias is as a dictionary where the key is the alias and value is the user_id
         with open('aliases.dat', 'rb') as alias_data:
             self.alias_data = pickle.load(alias_data)
     except FileNotFoundError:
         with open('aliases.dat', 'wb') as alias_data:
             self.alias_data = {}
             pickle.dump(self.alias_data, alias_data)
     try:
         # This file holds all the other random data thats saved by the bot
         with open('bot_data.dat', 'rb') as data:
             self.cur_dm = pickle.load(data)
     except FileNotFoundError:
         with open('bot_data.dat', 'wb') as data:
             self.cur_dm = '0'
             pickle.dump(self.cur_dm, data)
     try:
         with open('player_stats.dat', 'rb') as stats_data:
             self.stats_data = pickle.load(stats_data)
     except FileNotFoundError:
         with open('player_stats.dat', 'wb') as stats_data:
             self.stats_data = {}
             pickle.dump(self.stats_data, stats_data)
Example #5
0
    def __init__(self,
                 email,
                 password,
                 reply_dict,
                 mongo_db,
                 voice_choice=False,
                 **kwargs):
        Client.__init__(self, email, password)
        self.user_history = defaultdict(list)
        # self.user_history {thread_id: [[(bot_id, in_group_id, ab_test_id, msg, user_response_time), () ....], [], [], ...]}
        self.reply_dict = reply_dict
        self.user_name_dict = {}
        self.user_bot_dict = {}
        self.user_topic_dict = {}
        self.user_problem_dict = {}
        self.params = Params()
        self.config = Config()
        self.topics = Topics()

        self.db = mongo_db
        self.voice_choice = voice_choice

        additional_bot_control = kwargs.get('add_bot_ctl', {})
        if 'sleeping_time' in additional_bot_control:
            self.params.set_sleeping_time(
                additional_bot_control.get('sleeping_time'))

        if 'bot_choice' in additional_bot_control:
            self.params.set_bot_choice(
                additional_bot_control.get('bot_choice'))
    def __init__(self, username, password, thread_type, thread_id):
        self.THREAD_TYPE = thread_type
        self.THREAD_ID = thread_id

        Client.__init__(self, username, password, 'None', 1)

        # Defining the 'action' method

        def action(self):
            # Send Facebook message

            message = str(input('Message: '))

            while message != LOGOUT_MSG:
                try:
                    self.send(Message(text=message),
                              thread_id=self.THREAD_ID,
                              thread_type=self.THREAD_TYPE)

                    print('Facebook message sent.')
                except FBchatException:
                    print('Request failed.')

                message = str(input('Message: '))

            # Disconnect from Facebook

            self.logout()

            print('Disconnected.')
Example #7
0
    def __init__(self, email, password, classifier):
        Client.__init__(self, email, password)
        self.classifier = classifier
        self.splitter = re.compile('[ ,]+')
        # TODO build a training model using stack overflow data
        self.question_words = ['what', 'where', 'when','how','why','did','do','does','have','has','am','is','are','can','could','may','would','will','should'
"didn't","doesn't","haven't","isn't","aren't","can't","couldn't","wouldn't","won't","shouldn't"]
Example #8
0
 def __init__(self,
              email,
              password,
              test=True,
              debug=True,
              user_agent=None):
     Client.__init__(self, email, password)
     self.test = test
     self.modules = modules
Example #9
0
 def __init__(self, fbuser, fbpass, session):
     Client.__init__(
         self,
         fbuser,
         fbpass,
         session_cookies=session,
         max_tries=10,
         user_agent=
         "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36"
     )
     self.botanswer = BotAnswer(self.uid)
Example #10
0
 def __init__(self,eventbus,parser):
     with open('passwd.txt', 'r') as f:
         passwd = [a.strip() for a in f.readlines()]
     threading.Thread.__init__(self)
     Client.__init__(self,passwd[0],passwd[1])
     subscriber.__init__(self)
     
     self.parser = parser
     self.eb = eventbus
     print("Registering Topics")
     self.eb.register_consumer(self,EVENTID_CLIENT_SEND)
     self.eb.register_consumer(self,EVENTID_CLIENT_STOP)
     self.eb.register_consumer(self,EVENTID_CLIENT_START)
     self.eb.register_consumer(self,EVENTID_CLIENT_SNAPSHOT)
Example #11
0
 def __init__(self,
              email,
              password,
              currentPlayer=None,
              gameThread=None,
              application=None):
     """ Create a new PokerBot. Inherits from Client class of fbchat library. Additional
     attributes are currentPlayer (the player currently betting), gameThread (the facebook
     messenger thread that comprises the players of the game), and application (the pokergui
     application that handles the actual game)"""
     Client.__init__(self, email, password, max_tries=1)
     self.currentPlayer = currentPlayer
     self.gameThread = gameThread
     self.application = application
Example #12
0
	def __init__(self, email, password):
		
		self.scrollProcess = None
		self.users = {}
		
		self.actions = {
			"ohanes" : "say _ _ _ _   _ _ _",
			"time" : "show the current time"
		}

		client = Client.__init__(self, email, password)
Example #13
0
 def Clogin(self):
     try:
         with open('messenger.json', 'r') as f:
             cookie = json.load(f)
         Client.__init__(self,
                         "",
                         "",
                         user_agent=None,
                         session_cookies=cookie)
     except:
         while True:
             email = input("Email: ")
             password = getpass()
             cookie = None
             try:
                 Client.__init__(self, email, password)
                 break
             except Exception as e:
                 print(e)
                 print("Login error")
     if not cookie:
         self.storeCredentials(self.getSession()) if input(
             "Store credentials y/n? ") == "y" else None
    def __init__(self, username, password, thread_type, thread_id):
        self.THREAD_TYPE = thread_type
        self.THREAD_ID = thread_id

        Client.__init__(self, username, password, 'None', 1)
Example #15
0
    def __init__(self, user, password):
        Client.__init__(self, user, password)
        # The thread id for our group chat.
        # If the product were to be sold in the real world, the thread id would be assigned
        # to each user
        self.fish_tank_thread_id = '1863119160367263'

        # Sets the time when the lights must be turned on or off
        # Used for "one-off" light controls
        self.lights_off_time = None
        self.lights_on_time = None

        # Used to determine if the humidifier it increasing humidity
        # or if the water tank needs refilling
        self.hum_dev_history = []

        # On time, off time for daily light controls
        self.lights_schedule = [None, None]

        # initial tank statistics, needs to change at regular interval
        # daily_stats is used to store the average daily temps/humidity for the past year
        if DEMO:
            self.daily_stats = {
                "temp": [10, 20, 15, 18, 21, 25, 25],
                "hum": [75, 70, 76, 75, 78, 77, 74]
            }
        else:
            self.daily_stats = {"temp": [], "hum": []}

        # Stats for every minute
        self.tank_stats = {"temp": [], "hum": []}

        # Used to send updates to the user when a plant becomes happy/unhappy
        self.unhappy_plants = {
            "too cold": [],
            "too hot": [],
            "too dry": [],
            "too humid": []
        }

        #log the current day and month to check for new day
        self.old_dt = datetime.datetime.now()

        #the name of the user
        self.username = ""
        #initially the tank is empty
        self.inside_tank = []

        #data from plantDict.json
        #accessed using: plant_data[<plant_name>][<parameter>]
        #e.g. minimum_temperature_for_basil = plant_data["basil"]["min-temp"]
        self.plant_data = json.load(open('plantDict.json'))

        #There are 2 steps to setting up the tank: specifying name and plants
        self.WelcomeDialog = 2 * (int(not DEBUG))

        self.set_color_to_plant_health(0)

        #So it doesn't reply to itself
        self.exclude_text = []

        # Used to determine if the user needs to know the target settings
        self.display_status = False

        # Used to determine if the user only wants to know about one plant
        self.plant_of_interest = ""

        # Used to stop the client from constantly telling the user to refill
        # the water tank when it needs refilling
        self.send_refill_msg = True

        # Used to inform user so that they know the temperature and humidity is off auto
        self.manual_hum = None
        self.manual_temp = None

        # Used to inform the user that there is no target and that control is off
        # example use case: the fan is too noisy, so turn it off, even if it is too humid
        self.always_off = False

        #Startup greeting
        if not DEBUG:
            self.send_msg(
                "Hi, I am your new smart planter :) ! What may I call you?")
 def __init__(self, email, password, outputDir):
     Client.__init__(self, email, password)
     self.outputDir = outputDir
Example #17
0
 def __init__(self, email, password, **kwargs):
     Client.__init__(self, email, password)
     self.last_timestamp = 0
     self.receive_buffer = []
Example #18
0
 def __init__(self, email, password):
     Client.__init__(self, email=email, password=password)