def withdraw(self, text, sender_handle, sender_id):
        parts = text.split(" ")
        withdraw_address = ""
        amount = 0
        inputInValid = False
        reply_message = ""
        user_details = self.dataStore.getUserDetailsByTwitterHandle(
            f'@{sender_handle}')
        from_address = user_details['one_address']
        if len(parts) >= 3:
            if parts[0] == "!withdraw":
                print(text)
                try:
                    amount = float(parts[1])
                except Exception as ex:
                    inputInValid = True
                    reply_message = "Invalid withdrawal amount."
                    print(ex)
                if not inputInValid:
                    if amount < 0.00000000:
                        reply_message = f"Withdraw amount cannot be negative value."
                        print(reply_message)
                        inputInValid = True
                    else:
                        if HmyClient.getBalace(
                                from_address) + 0.00000021 < float(amount):
                            inputInValid = True
                            reply_message = f"Please make sure you have enough funds for transfer {amount} in your account including fees, please reduce the withdraw amount and try again."
                            print(reply_message)
                if not inputInValid:
                    withdraw_address = parts[2]
                    if not HmyClient.validateONEAdress(withdraw_address):
                        inputInValid = True
                        reply_message = "Invalid ONE address, transfer cancelled"
                        print(reply_message)

        if not inputInValid:
            res = HmyClient.transfer(from_address, withdraw_address, amount)
            res = eval(res)
            if 'transaction-hash' in res:
                reply_message = f"Withdraw is complete, here is the receipt {self.explorer_url}/tx/{res['transaction-hash']}"
            else:
                reply_message = "Withdraw is failed with unknown error"
        else:
            if reply_message == "":
                reply_message = "Unknown Error!"

        print(f'Withdraw reply :{reply_message}')
        self.api.send_direct_message(text=reply_message,
                                     recipient_id=sender_id)
 def balance(self, sender_handle, sender_id):
     try:
         # If they're not registered nor have they received any tips without an account
         user_details = self.dataStore.getUserDetailsByTwitterHandle(
             f'@{sender_handle}')
         if user_details != None:
             one_address = user_details['one_address']
             balance = HmyClient.getBalace(one_address)
             self.api.send_direct_message(
                 text=f'Your Wallet Balace \n{balance}',
                 recipient_id=sender_id)
         else:
             self.api.send_direct_message(
                 text=
                 f'You\'re not registered!, please register to get balance please register using Telegram bot (https://t.me/onetipbot), if you are already registered please link you twitter handle.',
                 recipient_id=sender_id)
         # Save the data
     except Exception as ex:
         print(ex)
 def process_tip(self, tweet_id, text, sender_handle, receiver):
     tip = 0
     success = "yes"
     failure_reason = ""
     tweet_type = "tweet"
     reply_text = ""
     print(text)
     print(f'@{self.bot_twitter_handle} !tip')
     if f'@{self.bot_twitter_handle} !tip' in text:
         if not self.dataStore.checkIftweetDataExists(tweet_id):
             sender_details = self.dataStore.getUserDetailsByTwitterHandle(
                 f'@{sender_handle}')
             if sender_details != None:
                 parts = text.split(" ")
                 for i in range(0, len(parts)):
                     if parts[i] == "!tip":
                         if i + 1 < len(parts):
                             tip = float(parts[i + 1])
                             break
                 from_address = sender_details['one_address']
                 sender = sender_handle
                 if receiver != "":
                     # Can't tip yourself
                     if sender != receiver:
                         # Can't tip more than you have
                         from_balance = HmyClient.getBalace(from_address)
                         if tip + 0.00000021 > from_balance:
                             reply_text = f'@{sender_handle}, your balance is low to tip {tip} ONE'
                         else:
                             receiver_details = self.dataStore.getUserDetailsByTwitterHandle(
                                 f'@{receiver}')
                             if receiver_details == None:
                                 reply_text = f"@{sender_handle}, @{receiver} is not registered with ONE Tipping bot, please register using Telegram bot (https://t.me/onetipbot)"
                             else:
                                 if 'one_address' in receiver_details:
                                     res = HmyClient.transfer(
                                         from_address,
                                         receiver_details['one_address'],
                                         tip)
                                     res = eval(res)
                                     if 'transaction-hash' in res:
                                         reply_text = f"Hi @{receiver}, @{sender_handle} just tipped you {tip} ONE"
                                     else:
                                         print(
                                             f"Tip failed from  {sender} to {receiver} tip {tip} ONE"
                                         )
                                 else:
                                     print(
                                         'Receiver ONE address is missing')
                     else:
                         reply_text = f'@{sender_handle} You can\'t tip yourself!'
                 else:
                     reply_text = f'@{sender_handle} Please mention a receiver to tip.'
             else:
                 success = "no"
                 failure_reason = "account does not exists"
                 reply_text = f'@{sender_handle} You are not registered with ONE Tipping bot, please register using Telegram bot (https://t.me/onetipbot).'
             if reply_text != "":
                 self.api.update_status(status=reply_text,
                                        in_reply_to_status_id=tweet_id)
                 print(reply_text)
             tweetDetails = {
                 'tweet_id': tweet_id,
                 'sender': sender_handle,
                 'receiver': receiver,
                 'tip': tip,
                 'text': text,
                 'replied': "yes",
                 'success': success,
                 'failure_reason': failure_reason,
                 'tweet_type': tweet_type,
                 'reply_text': reply_text
             }
             self.dataStore.saveTweetDetails(tweetDetails)
         else:
             print("Tweet already served")
     else:
         print("Not a Tipping tweet")