A judge told a man who sent a string of abusive messages to councillors in Garforth that he had narrowly escaped being sent to prison over it.
The bench at Leeds Magistrate's Court spent more than half an hour debating the fate of Daniel John Hallam before opting to give him a community service order.
At Friday's hearing, the court heard it stemmed from an altercation at the Bird In Hand pub in Garforth on May 31 with local councillors from the Garforth and Swillington Independent Party, where Hallam ended up getting barred due to that and a previous unrelated incident, said Paul Canfield, prosecuting.
Between Saturday June 1 and the middle of June, Hallam sent several messages to the political party's Facebook account, from his own personal account, in which he accused Coun Mark Dobson of being "sleazy, involved with young women and a dirty old man".
Hallam threatened to go to the press with his statements as well as branding the party racist, added Mr Canfield.
Over a similar period of time, messages were sent to Bird In Hand facebook account which is managed by Tracey Cooke, whom, Hallam called "gutter scum" and accused of selling alcohol to children. Again he threatened to tell the press of his views.
Anjum Nazir, mitigating for 37-year-old Hallam who lives with his mother at Lyndon Avenue, argued that the messages had been sent privately and not made public.
He added: "The reason they were sent were due to a previous incident involving Hallam and two councillors who are not the complainant. He felt aggrieved at the time because he states one of the councillors made a derogatory comment and referred to him as a paedophile. At some point the landlady of the pub became involved and barred him. He felt that the landlady had not behaved in an impartial manner.
"It was Mr Hallam letting off steam and having a rant but there is a fine line between what is acceptable and what is not and he overstepped the mark."
After adjourning, John Ashton, presiding magistrate, said: "Please be under no illusion that I have seriously reflected sending you to prison immediately. The starting point is nine weeks in custody. I have taken into account your guilty plea and had it not been for that custody would have been inevitable."
Hallam was ordered to undertake 200 hours of unpaid work and pay £150 compensation to each victim as well as court costs totalling £170.