Skype4Py - How to successfully add a contact? - python

I'm working to implement a few fun features with a SkypeBot, and one of the features I'd like to implement is the ability to add a new contact. While reviewing the Skype4Py docs, I note this method:
http://skype4py.sourceforge.net/doc/html/Skype4Py.client.Client-class.html#OpenAddContactDialog
I am using the following code to try to access this:
sky = Skype4Py.Skype()
client = Skype4Py.client.Client(sky)
sky.Attach()
client.OpenAddContactDialog("test")
However, when trying to utilize almost anything from Skype4py.client.Client I get a timeout with the traceback:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "build/bdist.macosx-10.8-intel/egg/Skype4Py/client.py", line 164, in OpenDialog
self._Skype._DoCommand('OPEN %s' % tounicode(' '.join(params)))
File "build/bdist.macosx-10.8-intel/egg/Skype4Py/skype.py", line 276, in _DoCommand
self.SendCommand(command)
File "build/bdist.macosx-10.8-intel/egg/Skype4Py/skype.py", line 778, in SendCommand
self._Api.send_command(Command)
File "build/bdist.macosx-10.8-intel/egg/Skype4Py/api/darwin.py", line 395, in send_command
raise SkypeAPIError('Skype command timeout')
SkypeAPIError: Skype command timeout
I receive this timeout error on every method I try to access within the client class. (ie:
OpenAuthorizationDialog, OpenCallHistoryTab, OpenContactsTab). Am I accessing this method incorrectly, or perhaps the method is not supported for newer versions of Skype? Any help with getting this working, or a method that adds contacts via Skype4Py successfully will be very appreciated.

sky = Skype4Py.Skype()
sky.Attach()
client = Skype4Py.client.Client(sky)
client.OpenAddContactDialog("Torxed")
Trying a few things out but i'm 99% sure that's the order in which you have to do things.
Otherwise you will time out because the attachment needs time to attach before you start executing things towards the API.
Also take a look at:
http://skype4py.sourceforge.net/doc/html/Skype4Py.user.User-class.html#SetBuddyStatusPendingAuthorization
http://skype4py.sourceforge.net/doc/html/Skype4Py.skype.SkypeEvents-class.html#UserAuthorizationRequestReceived
Also you might be going about this the wrong way.
Adding a skype user directly, is not how Skype works.
search
request add with a message
wait for authorization
So, try one of the following:
(one is a asyncore way of searching and adding as they pop up, the other will bunch your results)
http://skype4py.sourceforge.net/doc/html/Skype4Py.skype.Skype-class.html#AsyncSearchUsers
http://skype4py.sourceforge.net/doc/html/Skype4Py.skype.Skype-class.html#SearchForUsers
So try:
sky = Skype4Py.Skype()
sky.Attach()
print skyp.SearchForUsers('Torxed')
Should get you a handle to add me for instance.
Within the object that you recieve, there will be an option to add me for instance.

#Torxed's answer was right, but here's more information in case anyone wasn't able to make it the last mile.
I was able to add a contact in this way:
import Skype4Py
sky = Skype4Py.Skype()
sky.Attach()
requestMessage = "Please accept my request!"
searchResults = sky.SearchForUsers('echo123')
firstResult = searchResults[0]
firstResult.SetBuddyStatusPendingAuthorization(requestMessage)
Do be careful, though as this merely adds the FIRST result returned by the search. If you have the username exact, it should be fine.

Related

Unable to Sign Solana Transaction using solana-py throws not enough signers

using solana library from pip
pip install solana
and then trying to perform withdraw_from_vote_account
txn = txlib.Transaction(fee_payer=wallet_keypair.pubkey())
# txn.recent_blockhash = blockhash
txn.add(
vp.withdraw_from_vote_account(
vp.WithdrawFromVoteAccountParams(
vote_account_from_pubkey=vote_account_keypair.pubkey(),
to_pubkey=validator_keypair.pubkey(),
withdrawer=wallet_keypair.pubkey(),
lamports=2_000_000_000,
)
)
)
txn.sign(wallet_keypair)
txn.serialize_message()
solana_client.send_transaction(txn).value
This throw me an error
Traceback (most recent call last):
File "main.py", line 119, in <module>
solana_client.send_transaction(txn).value
File "venv/lib/python3.8/site-packages/solana/rpc/api.py", line 1057, in send_transaction
txn.sign(*signers)
File "venv/lib/python3.8/site-packages/solana/transaction.py", line 239, in sign
self._solders.sign(signers, self._solders.message.recent_blockhash)
solders.SignerError: not enough signers
I tried to workaround with adding more keypair to sign
txn.sign(wallet_keypair,validator_keypair)
Doing this it throws me an error on the sign method
self._solders.sign(signers, self._solders.message.recent_blockhash)
solders.SignerError: keypair-pubkey mismatch
not sure how to resolve this any help appreciated
The error message isn't very useful, but you need a blockhash on the message in your transaction in order to properly sign it, ie:
blockhash = solana_client.get_latest_blockhash().value['blockhash']
txn = txlib.Transaction(recent_blockhash=blockhash, fee_payer=wallet_keypair.pubkey())
A few other notes: txn.serialize_message() doesn't modify the transaction in place, but rather returns the transaction bytes, so there's no need to call it at all.
And finally, send_transaction actually does the work of fetching the blockhash and signing the transaction, so you can simplify the whole thing to:
txn = txlib.Transaction(fee_payer=wallet_keypair.pubkey())
txn.add(
vp.withdraw_from_vote_account(
vp.WithdrawFromVoteAccountParams(
vote_account_from_pubkey=vote_account_keypair.pubkey(),
to_pubkey=validator_keypair.pubkey(),
withdrawer=wallet_keypair.pubkey(),
lamports=2_000_000_000,
)
)
)
solana_client.send_transaction(txn, wallet_keypair).value
when you are trying to send a transaction that's withdrawing money from a wallet, you need the wallet that's holding the assets to sign a transaction to send the assets to the withdrawer.
anyway, from what i see you are trying to withdraw from vote_account_keypair, and withdrawer os wallet_keypair, in the code that you wrote you have only one signer which is wallet_keypair but you also need vote_account_keypair to sign the transaction becuz you are withdrawing from their account.
i hope this helps

Tapo plug using python with PyP100 library login error

I am using the basic script from the repository to try and connect to a Tapo P110 plug. Clearly I am using my ip/email/pword.
from PyP100 import PyP110
p110 = PyP110.P110("192.168.X.X", "email#gmail.com", "Password123") #Creating a P110 plug object
p110.handshake() #Creates the cookies required for further methods
p110.login() #Sends credentials to the plug and creates AES Key and IV for further methods
#PyP110 has all PyP100 functions and additionally allows to query energy usage infos
p110.getEnergyUsage() #Returns dict with all the energy usage
But I am getting this error.
Traceback (most recent call last):
File "c:\Users\xxxx\xxxx\Add-hoc analysis projects\tapo_plug_energy_monitor\Python\Basic_Tapo_script.py", line 9, in <module>
p110.getDeviceInfo()
File "C:\Users\xxxx\AppData\Local\Programs\Python\Python39\lib\site-packages\PyP100\PyP100.py", line 236, in getDeviceInfo
URL = f"http://{self.ipAddress}/app?token={self.token}"
AttributeError: 'P110' object has no attribute 'token'
I should note I tried to ping the ip and all packets transmitted and received correctly. It is login() that causes the error but I have checked login details and they seem to be correct. Any help appreciated.
So the problem was because of an update to the Tapo P110 firmware version 1.0.16
The current solution is to make a small change to PyP100.py see below link.
https://github.com/fishbigger/TapoP100/issues/76

running a simple pdblp code to extract BBG data

I am currently logged on to my BBG anywhere (web login) on my Mac. So first question is would I still be able to extract data using tia (as I am not actually on my terminal)
import pdblp
con = pdblp.BCon(debug=True, port=8194, timeout=5000)
con.start()
I got this error
pdblp.pdblp:WARNING:Message Received:
SessionStartupFailure = {
reason = {
source = "Session"
category = "IO_ERROR"
errorCode = 9
description = "Connection failed"
}
}
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/Users/prasadkamath/anaconda2/envs/Pk36/lib/python3.6/site-packages/pdblp/pdblp.py", line 147, in start
raise ConnectionError('Could not start blpapi.Session')
ConnectionError: Could not start blpapi.Session
I am assuming that I need to be on the terminal to be able to extract data, but wanted to confirm that.
This is a duplicate of this issue here on SO. It is not an issue with pdblp per se, but with blpapi not finding a connection. You mention that you are logged in via the web, which only allows you to use the terminal (or Excel add-in) within the browser, but not outside of it, since this way of accessing Bloomberg lacks a data feed and an API. More details and alternatives can be found here.

PRAW Errors updating to new Python Distro

So I am trying to create a bot that cross posts from a sub (r/pics) to (r/polpics) using a bit of code from u/GoldenSights. I upgraded to a new python distro and I get a ton of errors, I don't even know where to begin. Here is the code (formatting off, error lines bold):
Traceback (most recent call last):
File "C:\Users\tonyc\AppData\Local\Programs\Python\Python36-32\Lib\site-
packages\praw\subdump.py", line 84, in <module>
r = praw.Reddit(USERAGENT)
File "C:\Users\tonyc\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\praw\reddit.py", line 150, in __init__
raise ClientException(required_message.format(attribute))
praw.exceptions.ClientException: Required configuration setting 'client_id'
missing.
This setting can be provided in a praw.ini file, as a keyword argument to the `Reddit` class constructor, or as an environment variable.
This seems to be related to USERAGENT setting. I don't think I have that configured right.
USERAGENT = ""
# This is a short description of what the bot does. For example
"/u/GoldenSights' Newsletter bot"
SUBREDDIT = "pics"
# This is the sub or list of subs to scan for new posts.
# For a single sub, use "sub1".
# For multiple subs, use "sub1+sub2+sub3+...".
# For all use "all"
KEYWORDS = ["It looks like this post is about US Politics."]
# Any comment containing these words will be saved.
KEYDOMAINS = []
# If non-empty, linkposts must have these strings in their URL
This is the error line:
print('Logging in')
r = praw.Reddit(USERAGENT) <--here, this is error line 84
r.set_oauth_app_info(APP_ID, APP_SECRET, APP_URI)
r.refresh_access_information(APP_REFRESH)
Also in Reddit.py :
raise ClientException(required_message.format(attribute)) <--- error
praw.exceptions.ClientException: Required configuration setting 'client_id'
missing.
This setting can be provided in a praw.ini file, as a keyword argument to
the `Reddit` class constructor, or as an environment variable.
Firstly, you're going to want to have your API credentials stored externally in your praw.ini file. This makes things a lot more secure, and looks like it might go some way to fixing your issue. Here's what a completed praw.ini file looks like, including the useragent, so try to replicate this.
[DEFAULT]
# A boolean to indicate whether or not to check for package updates.
check_for_updates=True
# Object to kind mappings
comment_kind=t1
message_kind=t4
redditor_kind=t2
submission_kind=t3
subreddit_kind=t5
# The URL prefix for OAuth-related requests.
oauth_url=https://oauth.reddit.com
# The URL prefix for regular requests.
reddit_url=https://www.reddit.com
# The URL prefix for short URLs.
short_url=https://redd.it
[appname]
client_id=IE*******T14_w
client_secret=SW***********************CLY
password=******************
username=appname
user_agent=web:appname:1.0.0 (by /u/username)
Let me know how things go after you sort this out.

Using the recommended python parse.com library to wrap their REST api, why does the following occur

Code:
for k in dir(parse_rest.User):
print parse_rest.User[k]
Error:
Traceback (most recent call last):
File "/home/ntresch/Development/webapp/appcode.py", line 53, in <module>
for k in dir(parse_rest.User):
AttributeError: 'module' object has no attribute 'User'
The docs show the following:
#Users
#You can sign up, log in, modify or delete users as well, using the User object. You sign a user up as follows:
u = parse_rest.User.signup("dhelmet", "12345", phone="555-555-5555")
#or log in an existing user with
u = parse_rest.User.login("dhelmet", "12345")
# Once a User has been logged in, it saves its session so that it can be edited or deleted:
u.highscore = 300
u.save()
u.delete()
I really want to know what all I can do with the user object. This behavior seems wonky.
This was a case of (at the time) out-of-date documentation, fixed as of 3/11/2013. The way to access the User class is not parse_rest.User but:
from parse_rest.user import User
The answer is don't use that library. My colleague has one we home rolled checked into our source tree and we're planning on releasing one. When we do I will post a link here for completeness. :)

Categories

Resources