AttributeError: module 'telegram.ext.filters' has no attribute 'text' - python-telegram-bot

states={
MOB_NO: [MessageHandler(filters.text, reply_to)],
},
AttributeError: module 'telegram.ext.filters' has no attribute 'text'
I install pip install python-telegram-bot.
And here we import module.
from telegram.ext import (Updater, CommandHandler, MessageHandler, filters,
ConversationHandler)
When we handle messages it says.
AttributeError: module 'telegram.ext.filters' has no attribute 'text

Most probably you are using the latest version package. Downgrade the python-telegram-bot version to 13.7.
pip install python-telegram-bot==13.7 --force-reinstall
And use "Filters" with capital F

try using this one
from telegram.ext import filters
start_handler = ConversationHandler(
entry_points=[CommandHandler("start", start)],
states= {
"ONE": [MessageHandler(filters.TEXT, one)],
"TWO": [MessageHandler(filters.TEXT, two)],
},
fallbacks=[CommandHandler("cancel", start)]
)

Related

djangorestframework-simplejwt not working

I'm following a Udemy Course with user administration and I need to install this
pip install djangorestframework-simplejwt
After its installed, I need to add this to settings.py
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_simplejwt.authentication.JWTAuthentication',
)
}
But its gives me this error
ImportError: Could not import 'rest_framework_simplejwt.authentication.JWTAuthentication' for API setting 'DEFAULT_AUTHENTICATION_CLASSES'. ModuleNotFoundError: No module named 'pkg_resources'.
So far I haven't been been able to find anything on google
INSTALLED_APPS = [
...
'rest_framework_simplejwt',
...
]
It should be added in INSTALLED_APPS
Source: https://django-rest-framework-simplejwt.readthedocs.io/en/latest/getting_started.html

How to install golang package with custom tags in nix-shell?

I want to use go-migrate in my development environment, so I fill my shell.nix with
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
buildInputs = [
pkgs.go-migrate
];
}
But it will install go-migrate without any database drivers, so I can't use it. As I see in official installation instructions I should provide tags with needed database, but how to do it with nix?

How to install vue-chartkick and use it in my components?

I am using vue-chartkick with Laravel. I followed the documentation to install it.
npm install vue-chartkick chart.js
Then, in resources/js/app.js:
import Chartkick from 'vue-chartkick'
import Chart from 'chart.js'
Vue.use(Chartkick.use(Chart))
...
const app = new Vue({
el: '#app',
router: router,
vuetify: new Vuetify()
});
Then, when I put <line-chart :data="{'2017-01-01': 11, '2017-01-02': 6}"></line-chart> into a component, I get the following error in javascript console:
[Vue warn]: Unknown custom element: <line-chart> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
found in
---> <Dashboard> at resources/js/components/backend/Dashboard.vue
<VApp>
<Root>
What is the correct way to register the component ?
just use chart.js version 2.9 and vue-chartkick 0.6.1
npm install vue-chartkick#0.6.1 chart.js#2.9 --save
and import in app.js like below:
import {Chart} from 'chart.js'
import Chartkick from 'vue-chartkick'
Vue.use(Chartkick.use(Chart));
I used Chartkick with Fastapi. I struggled to implement it on the backend (no npm installer), then found the solution at https://github.com/ankane/vue-chartkick#installation
Put the code inside your main template file eg index.html:
My main.js file, running on fastapi server:
import { MyTitle } from "./title.js";
import { MyName } from "./name.js";
export const app = Vue.createApp({
delimiters: ["[[", "]]"],
data() {
return {};
},
});
app.component("MyTitle", MyTitle);
app.component("MyName", MyName);
app.use(VueChartkick);
const vm = app.mount("#app");

Error: Not found: 'dart:html' when using googleapis_auth dart team package with flutter

When using
googleapis_auth | Dart Package
googleapis | Dart Package
to access Google Api's thru Flutter using this code
import 'dart:convert';
import 'dart:io';
import 'package:googleapis_auth/auth.dart';
import 'package:googleapis_auth/auth_browser.dart';
import 'package:googleapis_auth/auth_io.dart';
import 'package:googleapis/androidpublisher/v3.dart';
Future main() async {
dynamic jsonData = json.decode(
await File('api-xxxxxxxxxxxxxxxxxxxx.json')
.readAsString());
var scopes = [AndroidpublisherApi.AndroidpublisherScope];
final accountCredentials = new ServiceAccountCredentials.fromJson(jsonData);
AuthClient client = await clientViaServiceAccount(accountCredentials, scopes);
}
you will get this error
Error: Not found: 'dart:html' import 'dart:html' as html;
Base on FAQ - Flutter :
Can Flutter run any Dart code?
Flutter should be able to run most Dart code that does not import (transitively, or directly) dart:mirrors or dart:html.
Problem synonym and analysis :
Look like you are using a package
which depends on 'dart:html'
which is not supported in Flutter
Solution :
remove
import 'package:googleapis_auth/auth_browser.dart';

Django 2.0.6 manage.py getting runserver error

I'm new on python and also try to learn a Django version 2.0.6 , so when i try to write the code with the documentation of Django here:
If faced a problem, specifically when I want to run the code, could help me to solve that issue please.
1- code (urls.py)folder polls:
from django.urls import path
from . import views
urlpatterns = [
path('',views.index, name= 'index'),
]
2- code (urls.py) folder mysite:
from django.contrib import admin
from django.urls import include,path
urlpatterns = [
path('admin/', admin.site.urls),
path('polls/',include('polls.Urls'))
]
3- code (views.py) folder mysite:
from django.http import HttpResponse
def index(request):
return HttpResponse("Hi world, you are walcome")

Resources