Commit ae35c3da authored by Christophe Le Clerc's avatar Christophe Le Clerc

ajout d'un flag media

ajoute l'option m (media) a la soumission d'un lien dans la RP
parent 7385519f
...@@ -17,6 +17,7 @@ CREATE TABLE IF NOT EXISTS `presse` ( ...@@ -17,6 +17,7 @@ CREATE TABLE IF NOT EXISTS `presse` (
`date_publi` datetime DEFAULT NULL, `date_publi` datetime DEFAULT NULL,
`hat` text, `hat` text,
`media` varchar(50) DEFAULT NULL, `media` varchar(50) DEFAULT NULL,
`is_media` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `note` (`note`) KEY `note` (`note`)
) ENGINE=MyISAM AUTO_INCREMENT=24233 DEFAULT CHARSET=latin1 ) ENGINE=MyISAM AUTO_INCREMENT=24233 DEFAULT CHARSET=latin1
...@@ -9,7 +9,7 @@ messages = { ...@@ -9,7 +9,7 @@ messages = {
"""Bonjour, je suis le bot de la Quadrature du Net, vous pouvez me demander de l'aide si besoin. (wantzel help)""", """Bonjour, je suis le bot de la Quadrature du Net, vous pouvez me demander de l'aide si besoin. (wantzel help)""",
"help": "help":
"""Mes commandes sont : ~help ~rp(cpa) ~status ~kill ~stats et ~admin. """Mes commandes sont : ~help ~rp(cpam) ~status ~kill ~stats et ~admin.
Pour plus d'informations, voir ici: https://wiki.laquadrature.net/Wantzel Pour plus d'informations, voir ici: https://wiki.laquadrature.net/Wantzel
Pour obtenir de l'aide sur une commande en particulier, il suffit de taper ~help <commande>""", Pour obtenir de l'aide sur une commande en particulier, il suffit de taper ~help <commande>""",
......
...@@ -368,7 +368,7 @@ class Wantzel(object): ...@@ -368,7 +368,7 @@ class Wantzel(object):
if "wantzel" in msg and ("help" in msg or "aide" in msg): if "wantzel" in msg and ("help" in msg or "aide" in msg):
self.help(user, channel, msg) self.help(user, channel, msg)
# Find known command # Find known command
command = re.search("[!~](rp[acp]*|status|kill|help|stats|admin)", msg) command = re.search("[!~](rp[acpm]*|status|kill|help|stats|admin)", msg)
Utils.debug("Command: %s" % command) Utils.debug("Command: %s" % command)
if command: if command:
Utils.debug("group(0): %s" % command.group(0)) Utils.debug("group(0): %s" % command.group(0))
...@@ -433,6 +433,7 @@ class Wantzel(object): ...@@ -433,6 +433,7 @@ class Wantzel(object):
Utils.debug("rp msg : %s" % msg) Utils.debug("rp msg : %s" % msg)
cite = 0 cite = 0
note = 1 note = 1
is_media = 0
answer = False answer = False
url = get_url(msg) url = get_url(msg)
Utils.debug("url: %s" % url) Utils.debug("url: %s" % url)
...@@ -449,6 +450,9 @@ class Wantzel(object): ...@@ -449,6 +450,9 @@ class Wantzel(object):
# Archive this article # Archive this article
if "a" in command: if "a" in command:
cite += 4 cite += 4
# this is media
if "m" in command:
is_media = 1
# Looking for such an article in database # Looking for such an article in database
cursor = get_cursor() cursor = get_cursor()
...@@ -470,9 +474,9 @@ class Wantzel(object): ...@@ -470,9 +474,9 @@ class Wantzel(object):
cursor.execute(""" cursor.execute("""
INSERT INTO presse SET INSERT INTO presse SET
url=%s, provenance=%s, cite=%s, note=%s, datec=NOW(), title='', url=%s, provenance=%s, cite=%s, note=%s, datec=NOW(), title='',
lang='', published=0, nid=0, screenshot=0, fetched=0, seemscite=0 lang='', published=0, nid=0, screenshot=0, fetched=0, seemscite=0, is_media=%s
""", """,
(url, user, cite, note) (url, user, cite, note, is_media)
) )
answer = True answer = True
else: else:
...@@ -586,7 +590,7 @@ class Wantzel(object): ...@@ -586,7 +590,7 @@ class Wantzel(object):
else: else:
url2 = "https" + url[4:] url2 = "https" + url[4:]
cursor.execute(""" cursor.execute("""
SELECT cite, nid, note SELECT cite, nid, note, is_media
FROM presse FROM presse
WHERE url = %s WHERE url = %s
OR url = %s""", OR url = %s""",
...@@ -607,6 +611,8 @@ class Wantzel(object): ...@@ -607,6 +611,8 @@ class Wantzel(object):
message += "publié (https://laquadrature.net/node/%s) / " % rows[0][1] message += "publié (https://laquadrature.net/node/%s) / " % rows[0][1]
else: else:
message += "non publié / " message += "non publié / "
if rows[0][3] == 1:
message += "media / "
self.send_message(channel, message[:-3]) self.send_message(channel, message[:-3])
def kill(self, user, channel, msg): def kill(self, user, channel, msg):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment