Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Commit

Permalink
Separate function
Browse files Browse the repository at this point in the history
  • Loading branch information
Nygon committed Jun 2, 2021
1 parent 226b1f7 commit 9ff9ba3
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 63 deletions.
62 changes: 0 additions & 62 deletions main.py

This file was deleted.

1 change: 0 additions & 1 deletion param.csv

This file was deleted.

52 changes: 52 additions & 0 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from asyncio.events import get_event_loop
import discord
from discord.ext import commands, tasks
import feedparser
import csv
from datetime import date
import asyncio

token = 'NDk1NzUwMDcxNjI4MDcwOTEy.W7AVOw.pIcPHMzRQCYzVfP_Ahhu2IlcRJI'
bot = commands.Bot(command_prefix='.')

@bot.event
async def on_ready():
feed_multi_news_rss.start()
print('bot in active')

@tasks.loop(seconds=20)
async def feed_multi_news_rss():
with open("param.csv") as csvfile:
reader = csv.DictReader(csvfile)

for row in reader:
await feed_news_rss(row)


async def feed_news_rss(row):
print(row["channel"])
await asyncio.sleep(1)

newsFeed = feedparser.parse(row["fluxrss"])
lineCount = 0

for entry in reversed(newsFeed.entries):
lineCount=+1

#get picture
picnews = entry.links[1].href

#set channel
channel = bot.get_channel(int(row["channel"]))

#set embed
print("ici")

e = discord.Embed()
e=discord.Embed(title=entry.title, url=entry.link, description=entry.summary, color=0xff0000)
e.set_author(name=row["name"])
e.set_footer(text=entry.published)
e.set_image(url=picnews)
#await channel.send(embed=e)

bot.run(token)
1 change: 1 addition & 0 deletions src/param.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fluxrss,name,channel,datelastpublishhttps://www.gameblog.fr/rss.php,Gameblog,849664021429747732,https://www.gameblog.fr/rss.php,Gameblog,849664039781138472,
Expand Down

0 comments on commit 9ff9ba3

Please sign in to comment.