Ich versuche, meine Telegram Bot Nachrichten über RSS Feed zu beantworten. Dazu benutze ich das Modul Feedparser. Jetzt habe ich es geschafft zu arbeiten, aber der Bot sendet 2 separate Nachrichten pro Feed-Element. Der erste hat die Zusammenfassung des Feeds und der zweite hat den Link. Ich möchte den Code ändern, so dass er es in 1 Nachricht sendet. Ich habe 2 verschiedene Methoden ausprobiert und beide haben Fehler gemacht.Telegramm Bot & Feed-Parser-> Antwort rss feed in 1 msg anstelle von 2
Arbeitsweise mit 2 msg pro Artikel:
elif text == "/news":
for i in range(3):
reply (feed.entries[i].summary)
reply (feed.entries[i].link)
Meine fehlgeschlagen fixes:
Fix1
elif text == "/news":
for i in range(3):
reply ((feed.entries[i].summary)
(feed.entries[i].link))
error1
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1102, in __call__
return handler.dispatch()
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "/base/data/home/apps/e~thalia-bot/1.391503855076259816/main.py", line 169, in post
(feed.entries[i].link))
TypeError: 'unicode' object is not callable
Fix2
elif text == "/news":
for i in range(3):
reply (feed.entries[i].summary.link)
Error2
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1102, in __call__
return handler.dispatch()
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "/base/data/home/apps/e~thalia-bot/1.391503917377816930/main.py", line 168, in post
reply (feed.entries[i].summary.link)
AttributeError: 'unicode' object has no attribute 'link'
Ich bin nicht sicher, was ich hier falsch gemacht haben, sah die Fehler bis zu versuchen und ein Update zu bekommen, aber noch keine funktionierende Lösung noch nicht gefunden. Würde mich freuen, wenn mir jemand in die richtige Richtung zeigen könnte.