Я хочу создать fbchatbot и использовать его вместе с kivy. Для этого мне нужно импортировать модули fbchat-asyncio, которые требуются для запуска чат-бота.
Я попытался включить модули fbchat-asyncio в строке требований в Buildozer.spe c file.
Я также попытался включить весь пакет папки fbchat-asyncio и создать дамп в папке .Buildozer
. Программа прекрасно работает на p c, но когда я запустил его на моем телефоне с файлом apk. Это cra sh в течение одной секунды. Я подозреваю, что это потому, что он не может распознать fbchat-asyncio
from kivy.uix.widget import Widget
#-*- coding: utf-8 -*-
from kivy.app import App
from fbchat import Client, ThreadType
import asyncio
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.uix.popup import Popup
from kivy.uix.textinput import TextInput
#
from kivy.uix.gridlayout import GridLayout
from kivy.uix.widget import Widget
from kivy.properties import ObjectProperty
import time
time.sleep(2)
#create a class to place all widget
class OurGrid(GridLayout):
def __init__(self,**kwargs): #kwarg mean can handle more parameter
super(OurGrid,self).__init__(**kwargs)
self.cols = 1 # can set the layout
self.inside = GridLayout()
self.inside.cols = 2
self.inside.add_widget(Label(text="User Name : ",italic=True,bold=True))
self.name = TextInput(multiline="false")
self.inside.add_widget(self.name)
# self.inside.add_widget(Label(text="Last Name : ",italic=True,bold=True))
# self.lastName = TextInput(multiline="false")
# self.inside.add_widget(self.lastName)
self.inside.add_widget(Label(text="Password : ",italic=True,bold=True))
self.password = TextInput(multiline="false")
self.inside.add_widget(self.password)
self.add_widget(self.inside)
#label -----
self.labelShow = Label(text=self.name.text)
self.add_widget(self.labelShow)
#add the label
self.btnLogin = Button(text="Login",font_size=30)
self.add_widget(self.btnLogin)
self.btnLogin.bind(on_press=self.press)
# btn1 = Button(text="Ok", italic=True)
# btn2 = Button(text="Exit", italic=True)
# self.add_widget(btn1)
# self.add_widget(btn2)
#btnLogin.bind(on_press=lambda *a: messageShow(self.email.text))
def press(self,instance):
name = self.name.text
password = self.password.text
if name !="" and password != "":
self.labelShow.text = "Login......"
class EchoBot(Client):
async def on_message(self, mid=None, author_id=None, message_object=None, thread_id=None,
thread_type=ThreadType.USER, at=None, metadata=None, msg=None):
await self.mark_as_delivered(thread_id, message_object.uid)
await self.mark_as_read(thread_id)
# If you're not the author, echo
if author_id != self.uid:
await self.send(message_object, thread_id=thread_id, thread_type=thread_type)
loop = asyncio.get_event_loop()
async def start():
client = EchoBot(loop=loop)
#print("Logging in...")
await client.start(name, password)
client.listen()
#
loop.run_until_complete(start())
loop.run_forever()
else:
self.labelShow.text = "Fail Login Pls Input all information"
#
self.labelShow.text = self.email.text
#name and email must be same in kivy file left
class MyApp(App): # get all method from the import app from the kivy
def build(self):
#build is what we gonna put inside the window
#we put a label inside a window
return OurGrid() # GET ALL THE INHERIT FROM MY GRID CLASS
#return Label(text="fafwfwa")
if __name__ =="__main__":
MyApp().run()#run the class so we get a label
Кто-нибудь знает, как я могу включить другие пакеты, такие как fbchat-asyncio, в apk kivy в телефоне?