Telegram botumdan rss feed'i ile haberleri yanıtlamaya çalışıyorum. Bunun için Feedparser modülünü kullanıyorum. Şimdi bunu işe almayı başardım ancak bot, feed öğesi başına 2 ayrı mesaj gönderiyor. İlki beslemenin özetine, ikincisinin de linki var. Kodu değiştirmek istedim, böylece 1 mesajda gönderir. 2 farklı yöntem denedim ve her ikisi de hatalarla geldi. ürün başına 2 msg ileTelegram bot & feed ayrıştırıcı-> rss feed'i 2 msn yerine 1 msg olarak gönderiliyor
Çalışma yöntemi:fix2
fix1
elif text == "/news":
for i in range(3):
reply ((feed.entries[i].summary)
(feed.entries[i].link))
HATA1
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
:
elif text == "/news":
for i in range(3):
reply (feed.entries[i].summary)
reply (feed.entries[i].link)
Benim düzeltmeleri başarısız
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'
Ben, burada yanlış yapmış denemek ve onarmak için uzun hataları baktım ancak henüz bir çalışma çözüm bulamadık ne emin değilim. Birisi bana doğru yönde işaret ederse sevinirim.