Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
uitsmmbot
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gruppo Socialmedia
uitsmmbot
Commits
8dd30d91
Commit
8dd30d91
authored
Jun 06, 2017
by
Pietro Albini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve text messages sent to the users
parent
585c1ba8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
23 deletions
+33
-23
uitsmmbot/auth.py
uitsmmbot/auth.py
+4
-4
uitsmmbot/post.py
uitsmmbot/post.py
+20
-10
uitsmmbot/settings.py
uitsmmbot/settings.py
+9
-9
No files found.
uitsmmbot/auth.py
View file @
8dd30d91
...
@@ -39,7 +39,7 @@ class AuthComponent(botogram.Component):
...
@@ -39,7 +39,7 @@ class AuthComponent(botogram.Component):
return
return
chat
.
send
(
"
\
n
"
.
join
((
chat
.
send
(
"
\
n
"
.
join
((
"*Non sei autorizzato a contattare questo bot!*"
,
"
‼️
*Non sei autorizzato a contattare questo bot!*"
,
"Chiedi all'amministratore di digitare "
"Chiedi all'amministratore di digitare "
"`/authorize %s`"
%
chat
.
id
"`/authorize %s`"
%
chat
.
id
)))
)))
...
@@ -52,12 +52,12 @@ class AuthComponent(botogram.Component):
...
@@ -52,12 +52,12 @@ class AuthComponent(botogram.Component):
def
authorize_command
(
self
,
message
,
args
):
def
authorize_command
(
self
,
message
,
args
):
"""Autorizza un ID a contattare il bot"""
"""Autorizza un ID a contattare il bot"""
if
len
(
args
)
!=
1
:
if
len
(
args
)
!=
1
:
message
.
reply
(
"*Uso:* `/authorize <id>`"
)
message
.
reply
(
"
‼️
*Uso:* `/authorize <id>`"
)
return
return
if
self
.
db
.
query
(
"SELECT id FROM auth WHERE id = ?;"
,
args
[
0
]):
if
self
.
db
.
query
(
"SELECT id FROM auth WHERE id = ?;"
,
args
[
0
]):
message
.
reply
(
"*Errore:* Chat già autorizzata!"
)
message
.
reply
(
"
‼️
*Errore:* Chat già autorizzata!"
)
return
return
self
.
db
.
update
(
"INSERT INTO auth (id) VALUES (?);"
,
args
[
0
])
self
.
db
.
update
(
"INSERT INTO auth (id) VALUES (?);"
,
args
[
0
])
message
.
reply
(
"La chat è ora *autorizzata* a contattare il bot."
)
message
.
reply
(
"
✅
La chat è ora *autorizzata* a contattare il bot."
)
uitsmmbot/post.py
View file @
8dd30d91
...
@@ -107,12 +107,12 @@ class PostComponent(botogram.Component):
...
@@ -107,12 +107,12 @@ class PostComponent(botogram.Component):
try
:
try
:
self
.
buffer
.
access_token
()
self
.
buffer
.
access_token
()
except
InvalidBufferTokenError
:
except
InvalidBufferTokenError
:
message
.
reply
(
"*Errore:* token di Buffer non valido!"
)
message
.
reply
(
"
‼️
*Errore:* token di Buffer non valido!"
)
return
return
# Check if this is a reply
# Check if this is a reply
if
message
.
reply_to_message
is
None
:
if
message
.
reply_to_message
is
None
:
message
.
reply
(
"*Rispondi* al messaggio contenente il post!"
)
message
.
reply
(
"
‼️
*Rispondi* al messaggio contenente il post!"
)
return
return
message_id
=
message
.
reply_to_message
.
message_id
message_id
=
message
.
reply_to_message
.
message_id
...
@@ -124,7 +124,7 @@ class PostComponent(botogram.Component):
...
@@ -124,7 +124,7 @@ class PostComponent(botogram.Component):
)
)
if
already_exists
:
if
already_exists
:
message
.
reply_to_message
.
reply
(
message
.
reply_to_message
.
reply
(
"*Errore:* stai già per pubblicare questo post."
"
‼️
*Errore:* stai già per pubblicare questo post."
)
)
return
return
...
@@ -181,7 +181,7 @@ class PostComponent(botogram.Component):
...
@@ -181,7 +181,7 @@ class PostComponent(botogram.Component):
message
,
social
,
message
,
social
,
)
)
if
not
data
:
if
not
data
:
query
.
message
.
edit
(
"*Operazione scaduta!*"
)
query
.
message
.
edit
(
"
‼️
*Operazione scaduta!*"
)
return
return
current
=
data
[
0
][
0
]
current
=
data
[
0
][
0
]
...
@@ -231,11 +231,21 @@ class PostComponent(botogram.Component):
...
@@ -231,11 +231,21 @@ class PostComponent(botogram.Component):
res
=
self
.
buffer
.
request
(
"post"
,
"updates/create.json"
,
data
=
data
)
res
=
self
.
buffer
.
request
(
"post"
,
"updates/create.json"
,
data
=
data
)
if
res
[
"success"
]:
if
res
[
"success"
]:
query
.
message
.
edit
(
"
\
n
"
.
join
((
# This will be sent to the user
"*Post inviato con successo!*"
if
action
==
"now"
else
socials
=
[
"*Post messo in coda!*"
,
"<code>- </code>%s: <b>%s</b>"
%
(
d
[
0
],
d
[
1
])
res
[
"message"
],
for
d
in
self
.
db
.
query
(
)))
"SELECT social_pretty, social_name FROM post_pending "
"WHERE message = ? AND post_there = 1;"
,
message
)]
query
.
message
.
edit
(
"
\
n
"
.
join
([
"✅ <b>Post inviato con successo!</b>"
if
action
==
"now"
else
"✅ <b>Post messo in coda!</b>"
,
""
,
"Account social selezionati:"
,
]
+
socials
),
syntax
=
"html"
)
# Queue the update also for Telegram
# Queue the update also for Telegram
if
telegram
:
if
telegram
:
...
@@ -263,7 +273,7 @@ class PostComponent(botogram.Component):
...
@@ -263,7 +273,7 @@ class PostComponent(botogram.Component):
)
)
else
:
else
:
query
.
message
.
edit
(
"
\
n
"
.
join
((
query
.
message
.
edit
(
"
\
n
"
.
join
((
"*Impossibile inviare il post:*"
,
"
‼️
*Impossibile inviare il post:*"
,
res
[
"message"
],
res
[
"message"
],
)))
)))
...
...
uitsmmbot/settings.py
View file @
8dd30d91
...
@@ -32,24 +32,24 @@ class SettingsComponent(botogram.Component):
...
@@ -32,24 +32,24 @@ class SettingsComponent(botogram.Component):
def
buffer_access_token
(
self
,
message
,
args
):
def
buffer_access_token
(
self
,
message
,
args
):
"""Imposta un nuovo token di Buffer"""
"""Imposta un nuovo token di Buffer"""
if
len
(
args
)
!=
1
:
if
len
(
args
)
!=
1
:
message
.
reply
(
"*Uso:* `/buffer_access_token <nuovo-token>`"
)
message
.
reply
(
"
‼️
*Uso:* `/buffer_access_token <nuovo-token>`"
)
return
return
try
:
try
:
self
.
buffer
.
set_access_token
(
args
[
0
])
self
.
buffer
.
set_access_token
(
args
[
0
])
except
InvalidBufferTokenError
:
except
InvalidBufferTokenError
:
message
.
reply
(
"Il token inserito *non è valido*!"
)
message
.
reply
(
"
‼️
Il token inserito *non è valido*!"
)
else
:
else
:
message
.
reply
(
"Il token di Buffer è stato *aggiornato*!"
)
message
.
reply
(
"
✅
Il token di Buffer è stato *aggiornato*!"
)
def
link_telegram
(
self
,
bot
,
message
,
args
):
def
link_telegram
(
self
,
bot
,
message
,
args
):
"""Collega un canale telegram al bot"""
"""Collega un canale telegram al bot"""
if
len
(
args
)
!=
1
:
if
len
(
args
)
!=
1
:
message
.
reply
(
"*Uso:* `/link_telegram <username-canale>`"
)
message
.
reply
(
"
‼️
*Uso:* `/link_telegram <username-canale>`"
)
return
return
if
self
.
db
.
query
(
"SELECT * FROM kw WHERE key = 'telegram_channel';"
):
if
self
.
db
.
query
(
"SELECT * FROM kw WHERE key = 'telegram_channel';"
):
message
.
reply
(
"*Errore:* c'è già un canale collegato."
)
message
.
reply
(
"
‼️
*Errore:* c'è già un canale collegato."
)
return
return
try
:
try
:
...
@@ -58,20 +58,20 @@ class SettingsComponent(botogram.Component):
...
@@ -58,20 +58,20 @@ class SettingsComponent(botogram.Component):
"user_id"
:
bot
.
itself
.
id
,
"user_id"
:
bot
.
itself
.
id
,
})[
"result"
][
"status"
]
})[
"result"
][
"status"
]
except
botogram
.
APIError
:
except
botogram
.
APIError
:
message
.
reply
(
"*Errore:* il canale non esiste!"
)
message
.
reply
(
"
‼️
*Errore:* il canale non esiste!"
)
return
return
if
status
!=
"administrator"
:
if
status
!=
"administrator"
:
message
.
reply
(
"*Errore:* il bot non è amministratore del canale!"
)
message
.
reply
(
"
‼️
*Errore:* il bot non è amministratore del canale!"
)
return
return
self
.
db
.
update
(
self
.
db
.
update
(
"INSERT INTO kw (key, value) VALUES ('telegram_channel', ?);"
,
"INSERT INTO kw (key, value) VALUES ('telegram_channel', ?);"
,
args
[
0
],
args
[
0
],
)
)
message
.
reply
(
"Canale *collegato* con successo!"
)
message
.
reply
(
"
✅
Canale *collegato* con successo!"
)
def
unlink_telegram
(
self
,
message
):
def
unlink_telegram
(
self
,
message
):
"""Rimuovi il collegamento dal canale telegram"""
"""Rimuovi il collegamento dal canale telegram"""
self
.
db
.
update
(
"DELETE FROM kw WHERE key = 'telegram_channel';"
)
self
.
db
.
update
(
"DELETE FROM kw WHERE key = 'telegram_channel';"
)
message
.
reply
(
"Link al canale Telegram *rimosso*."
)
message
.
reply
(
"
✅
Link al canale Telegram *rimosso*."
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment