i already have a working telegram bot on python, its working using api hash and app_id, and works instead of the user itself not an agent! after launching it requiers the two step verification on terminal, but on heroku there is no terminal, how can i run such a bot on heruku?
`
from telethon import TelegramClient, events, sync
import asyncio
api_id = ****
api_hash = '*****'
chat='https://t.me/joinchat/telchat'
bot='https://t.me/joinchat/second tell chat'
client = TelegramClient('usser', api_id, api_hash)
#client.on(events.NewMessage())
async def main(event):
await client.forward_messages(chat, event.message)
client.start()
client.run_until_disconnected()
`
I don't know if it can fix your whole problem, but you can check this article from heroku docs : here
Related
Working with Twilio conversation-demo app, but
ConversationsClient.create(this.state.token);
.create method is depreceated, so how can we initConversations.
And anyone can please help me how to do the sdk in react hooks.
with "#twilio/conversations": "^2.1.0", creating chat token from the ConversationsClient.create is deprecated. you should be creating a token from a server before you can use client instance as follows:
import {Client} from '#twilio/conversations'
const client = new Client(token)
I have an existing and functional Chat Bot with Google Dialogflow CX. The Chatbot is directly integrated in a website by the Google Bootstrap.
In some cases a Python script must trigger an intent or page for the user from the backend. In that case the user (and his client) should directly jump in this intent. The session ID of the user is known.
So far I managed it to set a parameter for the user from the python script using the following code.
from google.cloud import dialogflowcx_v3beta1 as dialogflow
from google.cloud.dialogflowcx_v3beta1 import types
session_id = "7826e7-0b7-794-b24-b95271869"
api_endpoint = f"{location_id}-dialogflow.googleapis.com"
client_options = {"api_endpoint": api_endpoint}
client = dialogflow.services.sessions.SessionsClient(client_options=client_options)
event = "live_chat_event"
params = {'message': "Hello World"}
event_input = types.EventInput(event=event)
query_input = types.QueryInput(event=event_input, language_code=language_code)
query_params = types.QueryParameters(parameters=params)
request = types.DetectIntentRequest(
session=session_path,
query_input=query_input,
query_params = query_params
)
response = client.detect_intent(request=request)
print(response.query_result.response_messages[0])
These parameters are then visible by the user on his client, but only after typing the next message.
I need the client to refresh itself or let it jump directly into the next page without any additional input from the user.
How can that be achieved?
Hey bro don't get complicated.
If you are struggling to get the DF API to work you are not the only one.
I can advise you to try the Voximplant Python Client so you can connect to your DF CX Agent easily and control that script . On top of that you can also handle calls with your DF CX or ES Agent.
You can check the documentation to add teh Credentials for DF here.
Also please check this Python API Client so you can run a Scenario that communicates with your CX Agent.
I have a problem when using the Telethon Python client for Telegram for logging in.
The script below works perfectly fine when I run it on my own laptop: it prints a SentCode object, Telegram sends me a confirmation code, and I use it to log in.
When I run exactly the same script on Heroku, it still prints the same SentCode object, however, I don't receive any confirmation code from Telegram and cannot continue logging in.
from telethon import sync # noqa
from telethon import TelegramClient
from telethon.sessions import StringSession
client = TelegramClient(session=StringSession(), api_hash=API_HASH, api_id=API_ID)
client.connect()
result = client.send_code_request(phone=PHONE)
print(result)
# prints SentCode(type=SentCodeTypeApp(length=5), phone_code_hash=..., next_type=CodeTypeSms(), timeout=None)
... the code for logging in and saving the session...
It seems that Telegram doesn't acknowledge authorization from Heroku for security reasons - maybe, Heroku is often used to host malicious bots, and Telegram fights them this way.
However, neither Telethon nor MTProto documentation reflects this restriction. So I wonder, how is it even possible to use MTProto clients like Telethon from a cloud platform? And if it is possible, what should I do to get around this restriction?
I want to access Amazon’s SES(Simple Email Service) using the boto3 library and a user profile. The code I want to execute is listed below which does not work. It gives me an error “botocore.exceptions.NoCredentialsError: Unable to locate credentials”, I am currently able to access S3 services with no issue so I know my profile is setup correctly, but I cannot find code to access the SES service using a profile. I need some pointers how to get the code to work.
SES code that NOT work
import boto3
session = boto3.session.Session(profile_name='myprofile')
client = boto3.client('ses','us-east-1')
response = client.list_verified_email_addresses()
S3 code which currently works with a profile
import boto3
session = boto3.session.Session(profile_name='myprofile')
s3 = session.resource('s3')
Reference: http://boto3.readthedocs.org/en/latest/reference/services/ses.html
In your SES code, you are not using the session that you created with your profile. But in S3 code, you use the session. When you call boto3.client(), it knows nothing about your profile. Try this:
session = boto3.Session(profile_name='myprofile')
client = session.client('ses','us-east-1')
response = client.list_verified_email_addresses()
I'm trying to create a program in Python that uses data from Yahoo Fantasy Sports API (Football to be specific). I've already registered an desktop app on the Yahoo Developer Network in order to get permission to use OAuth. I've also gotten the correct urls, client key, and client secret and other necessary information to run the program.
Currently, I am using this website as a resource: https://requests-oauthlib.readthedocs.org/en/latest/oauth1_workflow.html
I managed to complete the get request token phase **, but am now stuck at the **authorization phase, requiring me to get an oauth token and oauth verifier i believe.
However, I'm only able to receive an oauth token, and the methods I call do not return an oauth verifier at all, making it impossible to proceed to the access token step. I'm just looking for some possibilities as to why this is the case.
Thanks.
import csv
import requests
import sys
import time
import webbrowser
from oauth_hook import OAuthHook
from requests_oauthlib import OAuth1Session
from requests_oauthlib import OAuth1
from urlparse import parse_qs
access_token_url = "https://api.login.yahoo.com/oauth/v2/get_token"
request_token_url = "https://api.login.yahoo.com/oauth/v2/get_request_token"
base_authorization_url = "https://api.login.yahoo.com/oauth/v2/request_auth"
callback_URL = "auto-manager.com"
client_key = ".." #can't reveal actual client stuff here
client_secret = ".."
#get request token
oauth = OAuth1Session(client_key,client_secret=client_secret)
print oauth
fetch_response = oauth.fetch_request_token(request_token_url)
resource_owner_key = fetch_response.get('oauth_token')
resource_owner_secret = fetch_response.get('oauth_token_secret')
print fetch_response
print resource_owner_key
print resource_owner_secret
# get authorization, returns no verifier but returns a token for some reason, PROBLEM's here
authorization_url = oauth.authorization_url(base_authorization_url)
print 'please go here and authorize,', authorization_url
redirect_response = raw_input('Paste full redirect URL here: ')
oauth_response = oauth.parse_authorization_response(redirect_response)
print oauth_response
The main issue i've found with requets_oauthlib is that it doesn't let you kind of customize stuff such as headers and body content. I've tried to use it for Yahoo OAuth but i got stuck because of that.
I turned to rauth, with which i managed to make things work. I even developed a special OAuth Lib for Yahoo which supports OAuth1 and OAuth2.
The lib is named yahoo-oauth.
Hope it will help you out.
Have a good one