I am trying to make a Telegram Bot. But getting error, don't know how to get rid of it - python-telegram-bot

thats a simple code and Cmd output line
bot name - #ting_ting_bot

Ok, instead of telebot.Telebot use telebot.TeleBot. Note that B in TeleBot.
In the docs of pyTelegramBotApi's docs it is provided:
import telebot
bot = telebot.TeleBot("TOKEN", parse_mode=None) # You can set parse_mode by default. HTML or MARKDOWN

Related

AttributeError: 'User' object has no attribute 'guild_permissions'

enter image description here
Hi Hello I have a question, why did I actually get this error I want to know what he actually says and I would love to get a detailed explanation.
Firstly, please provide atleast some code for context. Secondly, don't post a screenshot of the error, just include it as a codeblock in your post. That being said, my best guess from the limited information is that you need to use ctx.message.author. In your error screenshot, it seems you are just using message.author.
The guild_permissions.administrator is not exists on discord.py and that's why you getting "User" object has no attribute 'guild_permissions' error and you do not need to post a screenshot here but it's okay.
Also do you have the has_permissions?
If you do not have then
from discord.ext import commands, tasks
from discord.ext.commands import is_owner, has_permissions, MissingPermissions, BadArgument
If you do, use
#client.command()
#has_permissions(administrator=True)
async def command(ctx):
#yourscript
That's just my opinion what i was thinking.
If you're using on_message then please provide a script what you did.

why scrapy won't load any of my pipelines?

ok, so Im using Scrapy for some basic web scraping and its working fine on scraping part! when get some output using feed export something like -o output.csv wont do anything, it will make an empty file but nothing else.
after a period of confusion I couldn't make it work so i've decided to use a pipeline to write some custom method of exporting. but now the problem is even though the application is working fine... its just not load the pipelines. not any single one of them is not running and there is no error.
this is my settings.py where I put the option to load them:
ITEM_PIPELINES = {
'fbcrawl.pipelines.CsvExporterPipeline': 300
}
and this is my CsvExporterPipeline class inside pipelines.py:
class CsvExporterPipeline(object):
def process_item(self, item, spider):
print('\n' * 2)
print(item)
print('\n' * 2)
return item
and its not gonna run neither of these 3 prints wont run at all.
I want to know how can I have my pipelines loaded and working?
UPDATE: i forgot to mention that im trying to run this code... so the spider is mentioned here:
https://github.com/rugantio/fbcrawl
Are you sure BOT_NAME in settings.py is set at fbcrawl ?
And what is the code of your spider ?

How to convert RASA base Text bot to Rasa base Voice Bot

I already inserted the value for the RASA NLU using text format but I want insert that value using voice command. I already create google voice to text file to get the text out put. But I didn't understand how to move that text value into my Rasa NLU. I am using Rasa Open Source.
It's difficult to understand what exactly you're doing without the code. But since you say that you get the text output, you can use it as a message sent to rasa Agent:
from rasa.core.agent import Agent
from rasa.utils.endpoints import EndpointConfig
async def chat(message):
agent = Agent.load("/path/to/your/model")
respond = await agent.handle_text(message)
return respond
asyncio.run(chat("hi"))

Displaying JSON output from an API call in Ruby using VScode

For context, I'm someone with zero experience in Ruby - I just asked my Senior Dev to copy-paste me some of his Ruby code so I could try to work with some APIs that he ended up putting off because he was too busy.
So I'm using an API wrapper called zoho_hub, used as a wrapper for Zoho APIs (https://github.com/rikas/zoho_hub/blob/master/README.md).
My IDE is VSCode.
I execute the entire length of the code, and I'm faced with this:
[Done] exited with code=0 in 1.26 seconds
The API is supposed to return a paginated list of records, but I don't see anything outputted in VSCode, despite the fact that no error is being reflected. The last 2 lines of my code are:
ZohoHub.connection.get 'Leads'
p "testing"
I use the dummy string "testing" to make sure that it's being executed up till the very end, and it does get printed.
This has been baffling me for hours now - is my response actually being outputted somewhere, and I just can't see it??
Ruby does not print anything unless you tell it to. For debugging there is a pretty printing method available called pp, which is decent for trying to print structured data.
In this case, if you want to output the records that your get method returns, you would do:
pp ZohoHub.connection.get 'Leads'
To get the next page you can look at the source code, and you will see the get request has an additional Hash parameter.
def get(path, params = {})
Then you have to read the Zoho API documentation for get, and you will see that the page is requested using the page param.
Therefore we can finally piece it together:
pp ZohoHub.connection.get('Leads', page: NNN)
Where NNN is the number of the page you want to request.

“Error no label add or removes specified” when trying to modify labels using Gmail's Ruby API

I've looked at https://www.rubydoc.info/github/google/google-api-ruby-client/Google/Apis/GmailV1/ModifyThreadRequest and the examples https://developers.google.com/gmail/api/v1/reference/users/labels/update for Python and JS but can't figure out how to format the request properly in ruby.
I'm trying:
service.modify_thread('me',thread_id,{'add_label_ids'=>['UNREAD']})
and various other permutations of the object but can't get anything other than Google::Apis::ClientError: invalidArgument: No label add or removes specified in response.
Any help appreciated
modify_thread expects a Google::Apis::GmailV1::ModifyThreadRequest object as third argument according to the documentation.
In the source of the constructor of ModifyThreadRequest you can see that it looks for a key :add_label_ids in its arguments.
So if modify_thread creates the ModifyThreadRequest object itself then
service.modify_thread('me',thread_id, add_label_ids: ['UNREAD'])
should work.
If that fails I would try
mtr = Google::Apis::GmailV1::ModifyThreadRequest.new(add_label_ids: ['UNREAD'])
service.modify_thread('me', thread_id, mtr)

Resources